我已经在我的代码中成功实现了ActionBar-PullToRefresh.现在每当我刷新列表时,它都会在ActionBar中显示"正在加载..."文本.
那么如何在ActionBar中更改该文本.我是否直接更改了库中的字符串,还是有其他方法可以做到这一点......
目前我使用Styles.xml结合java代码来定义PullToRefresh定制.我想只通过java代码进行所有自定义,而不是用XML定义它们.我可以以编程方式实现所有自定义吗?
这是我的xml自定义:
<!-- PullToRefresh Customizations -->
<style name="Theme.Holo.CustomPtrHeader" parent="Theme.Sherlock">
<item name="ptrHeaderStyle">@style/Widget.Custom.PtrHeader</item>
</style>
<style name="Widget.Custom.PtrHeader" parent="android:Widget">
<!-- The background of the header view -->
<item name="ptrHeaderBackground">#FF69B4</item>
<!-- Color to tint the progress bar -->
<item name="ptrProgressBarColor">#FF69B4</item>
<!-- The strings to be displayed at the various states -->
<item name="ptrPullText">Pull To Refresh</item>
<item name="ptrRefreshingText">Refreshing News</item>
<item name="ptrReleaseText">Loading...</item>
</style>
Run Code Online (Sandbox Code Playgroud)
Java代码:
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ViewGroup viewGroup = (ViewGroup) view;
mPullToRefreshLayout = new PullToRefreshLayout(activity);
ActionBarPullToRefresh
.from(activity)
.insertLayoutInto(viewGroup)
.theseChildrenArePullable(R.id.gridview_news_grid, …Run Code Online (Sandbox Code Playgroud) 嗨,每次我使用拉动刷新时,我的数据都会重复。例如。通过一次拉动刷新,表视图中的 5 个初始条目将增加一倍至 10 个,并在随后的拉动刷新中再添加 5 个条目。我怎样才能停止重复..我想确保只下载新项目,并且不会再次下载表中的现有数据。
\n\n@implementation RootViewController\n@synthesize allEntries = _allEntries;\n@synthesize feeds = _feeds;\n@synthesize queue = _queue;\n@synthesize webViewController = _webViewController;\n\n#pragma mark -\n#pragma mark View lifecycle\n\n- (void)addRows {\n\n RSSEntry *entry1 = [[[RSSEntry alloc] initWithBlogTitle:@"1"\n articleTitle:@"1"\n articleUrl:@"1"\n articleDate:[NSDate date]] autorelease];\n RSSEntry *entry2 = [[[RSSEntry alloc] initWithBlogTitle:@"2"\n articleTitle:@"2"\n articleUrl:@"2"\n articleDate:[NSDate date]] autorelease];\n RSSEntry *entry3 = [[[RSSEntry alloc] initWithBlogTitle:@"3"\n articleTitle:@"3"\n articleUrl:@"3"\n articleDate:[NSDate date]] autorelease];\n\n\n [_allEntries insertObject:entry1 atIndex:0];\n [_allEntries insertObject:entry2 atIndex:0];\n [_allEntries insertObject:entry3 atIndex:0];\n\n}\n\n\n\n\n- (void)viewDidLoad {\n [super viewDidLoad]; \n self.title = @"Songs";\n self.allEntries …Run Code Online (Sandbox Code Playgroud) 这是我的刷新控件代码。(代码已更新为整个 ViewController 代码以便更好地理解)
import UIKit
class AirportTableViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, AirportRequestDelegate {
@IBOutlet weak var airportTable: UITableView!
var airportRequest = AirportRequest()
var airportList = [AirportDetail]()
var refreshControl = UIRefreshControl()
override func viewDidLoad() {
super.viewDidLoad()
self.title = "Airport List"
airportTable.delegate = self
airportRequest.delegate = self
airportRequest.fetchAirports()
airportTable.dataSource = self
refreshControl.addTarget(self, action: #selector(refresh), for: UIControl.Event.valueChanged)
airportTable.addSubview(refreshControl)
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return airportList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let myCell …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Introspect 库在下拉发生时刷新 SwiftUI 中的列表控件。
我的列表修改器如下:
.introspectTableView (tableView in {
tableView.refreshControl = UIRefreshControl()
// code here to get new data
tableView.refreshControl?.endRefreshing()
}
Run Code Online (Sandbox Code Playgroud)
获取新数据的代码继续执行。
任何帮助,将不胜感激。