本文整理汇总了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;
}