ListView滚动到指定位置

setSelection(int position)

setSelection Added in API level 1


/**
 * position int: Index (starting at 0) of the data item to be
 *          selected.
 */
void setSelection (int position)

Sets the currently selected item. If in touch mode, the item will not be selected but it will still be positioned appropriately. If the specified selection position is less than 0, then the item at position 0 will be selected.


smoothScrollByOffset(int offset)

smoothScrollByOffset Added in API level 11


/**
 *offset    int: The amount to offset from the adapter position   
 *          to scroll to.
 */
void smoothScrollByOffset (int offset)
Smoothly scroll to the specified adapter position offset. The view will scroll such that the indicated position is displayed.

smoothScrollToPosition(int position)

smoothScrollToPosition Added in API level 8

/**
 * position int: Scroll to this adapter position.
 */
void smoothScrollToPosition (int position)
Smoothly scroll to the specified adapter position. The view will scroll such that the indicated position is displayed.

猜你喜欢

转载自blog.csdn.net/huagbo/article/details/60476923