我正在使用这个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.
}
问题是:
加载时,它会破坏底部列表视图的40%,当它得到
加载后,它会打断ListView20%的部分,最后显示整个
列表视图。
我遗漏了什么吗?请帮忙。
谢谢您。
最佳答案
不是解决问题的方法,但请使用:
https://github.com/chrisbanes/Android-PullToRefresh
尽管上面写着
请注意,此项目不再被维护
它工作完美,界面流畅。
比如@udi oshi建议你也可以使用类似于gmail的pull刷新:
https://github.com/chrisbanes/ActionBar-PullToRefresh
关于android - 拉入刷新:动画时ListView中断,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16996285/