本文整理匯總了Java中android.widget.ListView.smoothScrollToPositionFromTop方法的典型用法代碼示例。如果您正苦於以下問題:Java ListView.smoothScrollToPositionFromTop方法的具體用法?Java ListView.smoothScrollToPositionFromTop怎麽用?Java ListView.smoothScrollToPositionFromTop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ListView
的用法示例。
在下文中一共展示了ListView.smoothScrollToPositionFromTop方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: smoothScrollListView
import android.widget.ListView; //導入方法依賴的package包/類
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);
}
}
示例2: scrollToTop
import android.widget.ListView; //導入方法依賴的package包/類
/**
* 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;
}
示例3: scrollToItem
import android.widget.ListView; //導入方法依賴的package包/類
/**
* 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;
}