Back to project page FeedListViewDemo.
The source code is released under:
MIT License
If you think the Android project FeedListViewDemo listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package io.bxbxbai.androiddemos.utils; //from w ww . jav a2s . co m import android.os.Build; import android.widget.AbsListView; import android.widget.ListView; /** * Created by storm on 14-4-11. */ public class ListViewUtils { private ListViewUtils() { } /** * ??????? * * @param listView */ public static void smoothScrollListViewToTop(final AbsListView listView) { if (listView == null) { return; } smoothScrollListView(listView, 0); listView.postDelayed(new Runnable() { @Override public void run() { listView.setSelection(0); } }, 200); } /** * ?????position * * @param listView * @param position */ public static void smoothScrollListView(AbsListView listView, int position) { if (Build.VERSION.SDK_INT > 7) { listView.smoothScrollToPositionFromTop(0, 0); } else { listView.setSelection(position); } } }