我是Android新手。我的要求是加載額外的數據&設置到列表視圖,當滾動到達底部。我可以調用下一個數據,但我以前的數據是隱藏的。如何糾正?滾動達到底部時加載更多數據
listView.setOnScrollListener(new OnScrollListener() {
@Override
public void onScrollStateChanged(AbsListView view,
int scrollState) {
// TODO Auto-generated method stub
}
@Override
public void onScroll(AbsListView view,
int firstVisibleItem, int visibleItemCount,
int totalItemCount) {
// TODO Auto-generated method stub
if (listView.getLastVisiblePosition() == listView
.getAdapter().getCount() - 1
&& listView.getChildAt(
listView.getChildCount() - 1)
.getBottom() <= listView
.getHeight()) {
// scroll end reached
if (nextCall == null || nextCall == ""
|| nextCall.equals("null")
|| nextCall.equals("")) {
} else {
hostname=nextCall;
new ArticlesList().execute();
}
// Write your code here
}else{
}
}
});
dialog.dismiss();
} else {
Toast.makeText(getActivity(), "Went wrong",
Toast.LENGTH_LONG).show();
dialog.dismiss();
}
考慮使用'ScrollView'而不是'ListView',它是'onScrollChanged'方法來識別何時到達ScrollView的底部。 – 2014-12-04 08:40:49