以下是我解決了這個,希望這將幫助那些搜索。關鍵是將OnScrollListener附加到列表中,跟蹤正在處理的時間,以及何時到達列表的末尾。然後,當投擲仍在繼續時,如果系統嘗試移動它,則繼續將位置重置到最後。
private ListView mListView;
private ListAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my_list);
mListView = (ListView) findViewById(R.id.listView);
mAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, getList(25));
mListView.setAdapter(mAdapter);
mListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
if(Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD || Build.VERSION.SDK_INT == Build.VERSION_CODES.GINGERBREAD_MR1){
mListView.setOnScrollListener(new OnScrollListener(){
private boolean flinging = false;
private boolean reachedEnd = false;
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
flinging = (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING);
reachedEnd = false;
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
if(reachedEnd && flinging && (firstVisibleItem + visibleItemCount < totalItemCount)){
mListView.setSelection(mAdapter.getCount() - 1);
}else if(firstVisibleItem + visibleItemCount == totalItemCount){
reachedEnd = true;
}else{
reachedEnd = false;
}
}
});
}
}
檢查這個答案: http://stackoverflow.com/questions/5778820/is-there-a-way-to-disable-android-listview-animation – vladexologija 2012-10-23 14:53:58
檢查這個答案。完美的作品。 http://stackoverflow.com/questions/7777803/listview-top-highlight-on-scrolling/17569996#17569996 – kord 2013-07-10 12:02:23
你有沒有想過一個解決惱人的反彈效應?我也在我的列表視圖中看到它。 – Brian 2014-03-05 21:57:13