Java Code Examples for android.widget.ListView.smoothScrollToPositionFromTop()

The following are Jave code examples for showing how to use smoothScrollToPositionFromTop() of the android.widget.ListView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: boohee_v5.6   File: ListViewUtils.java   Source Code and License Vote up 6 votes
public static void smoothScrollListView(ListView listView, int position) {
    if (VERSION.SDK_INT >= 11) {
        listView.smoothScrollToPositionFromTop(0, 0);
    } else if (VERSION.SDK_INT >= 8) {
        listView.smoothScrollToPosition(0);
    } else {
        listView.setSelection(position);
    }
}
 
Example 2
Project: LuaViewPlayground   File: UDBaseListView.java   Source Code and License Vote up 5 votes
/**
 * listview滚动到顶部
 *
 * @param animate 是否动画
 * @return
 */
public UDBaseListOrRecyclerView scrollToTop(final int offset, final boolean animate) {
    final ListView lv = getListView();
    if (lv != null) {
        if (animate) {
            if (lv.getFirstVisiblePosition() > 7) {//hack fast scroll
                lv.setSelection(7);
            }
            lv.smoothScrollToPositionFromTop(0, offset);
        } else {
            lv.setSelectionFromTop(0, offset);
        }
    }
    return this;
}
 
Example 3
Project: LuaViewPlayground   File: UDBaseListView.java   Source Code and License Vote up 5 votes
/**
 * listview滚动到某个位置
 *
 * @param section
 * @param rowInSection
 * @param offset
 * @return
 */
public UDBaseListOrRecyclerView scrollToItem(final int section, final int rowInSection, final int offset, final boolean animate) {
    final ListView lv = getListView();
    if (lv != null) {
        if (animate) {
            lv.smoothScrollToPositionFromTop(getPositionBySectionAndRow(section, rowInSection), offset);
        } else {
            lv.setSelectionFromTop(getPositionBySectionAndRow(section, rowInSection), offset);
        }
    }
    return this;
}