我正在使用此PullToRefresh代码:
https://github.com/erikwt/PullToRefresh-ListView
XML代码:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/bg_listview_grey" >
<eu.erikw.PullToRefreshListView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="6dp"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:layout_marginTop="6dp"
android:divider="@color/bg_listview_grey"
android:dividerHeight="6dp"
android:drawSelectorOnTop="true"
android:scrollbars="none" />
</RelativeLayout>
与ListView相关的活动代码:
listView = (PullToRefreshListView) view
.findViewById(R.id.feedListView);
footerView = inflater.inflate(R.layout.footer, listView, false);
feedListView.addFooterView(footerView);
listAdapter = new DefaultFeedAdapter((Activity) getSherlockActivity(),
list_items, listView);
listView.setAdapter(listAdapter);
feedListView.setOnScrollListener(new OnScrollListener() {
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// what is the bottom item that is visible
int lastInScreen = firstVisibleItem + visibleItemCount;
// is the bottom item visible & not loading more already ? Load
// more !
if ((lastInScreen == totalItemCount) && totalItemCount >= 3
&& !LoadingNextData && !noMoreItems) {
lastId = listAdapter.values.get(totalItemCount - 3).id;
LoadingNextData = true;
new GetNewItems().execute("" + lastId);
}
}
});
listView.setOnRefreshListener(new OnRefreshListener() {
@Override
public void onRefresh() {
new RefreshList().execute("");
}
});
private class RefreshFeed extends AsyncTask<String, Void, String> {
//adds items at the top of the list if there are any.
//But even without any new items ie.. without touching
//the listView, it breaks.
}
问题是:
加载时,它会打破底部listView的40%以及它何时获得 加载它打破了listView的大约20%,最后显示整个 的ListView。
我错过了什么吗?请帮忙。
谢谢。
答案 0 :(得分:2)
不是问题的解决方案,而是使用它:
<强> https://github.com/chrisbanes/Android-PullToRefresh 强>
虽然它说
请注意,这个项目不再是维持
界面流畅,完美无瑕。
像@Udi Oshi建议你也可以使用Gmail Like来刷新:
<强> https://github.com/chrisbanes/ActionBar-PullToRefresh 强>
答案 1 :(得分:1)
我认为这是该库的已知问题,因为即使他们在Issues on git
中关闭了这个问题,它仍然会发生我建议您使用新的Pull to refresh - Gmail like。奇迹般有效。玩得开心