@Override
public void onScroll(AbsListView view, int firstVisibleItem,
int visibleItemCount, int totalItemCount) {
// TODO Auto-generated method stub
Toast.makeText(ViewPage.this, "In" , 1).show();
if (loading)
{
if (totalItemCount > previousTotal)
{
loading = false;
previousTotal = totalItemCount;
currentPage++;
}
}
if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem + visibleThreshold))
{
for(int i=0;i<5;i++)
{
filename[i] = contactcursor.getString(contact_column_index);
Toast.makeText(ViewPage.this, filename[i] +" "+ contactcursor.getString(contact_column_index) , 1).show();
contactcursor.moveToNext();
}
arr_ad = new ArrayAdapter<String>(ViewPage.this, android.R.layout.simple_list_item_1, filename);
setListAdapter(arr_ad);
// I load the next page of gigs using a background task,
// but you can call any function here.
// new LoadGigsTask().execute(currentPage + 1);
loading = true;
Toast.makeText(ViewPage.this,totalItemCount+" "+visibleItemCount+" "+firstVisibleItem+" "+visibleThreshold+" ", 1).show();
}
}
这是代码的一部分,其中 onScroll 应该只在 listview 向下滚动时才起作用,但是当活动开始时它会自动工作,因为其中的 toast 被打印出来。提前谢谢。