ListView(一)

来源:互联网 发布:java 上传文件到http 编辑:程序博客网 时间:2024/06/05 23:53

理论部分

1、ListView是最常用的控件之一,其知识点和用法对我来说纷繁复杂

2、最常用的用法就是:ListView配合BaseAdapter使用

3、方法1:

      public View getChildAt (int index)   Since:API Level 1

      Returns the view at the specified position in the group.

      译文:返回当前组指定位置的View:(1)当前所显示的所有Item成为一组

     (2)index的确定:从0开始,这一组的最上面是index为0,以此类推。

     方法2:

     public int getFirstVisiblePosition()     Since:API Level 1

     Returns the position within the adapter's data set for the first item displayed on screen.

     译文:顾名思义,返回当前group的第一个可见Item在所有Item中的位置,也是从0开始;比如说,当前

     屏幕上显示2,3,4,一共有1,2,3,4,那么返回值是1。

      方法2:

     public void setSelectionFromTop(int position, int y)     Since: API Level 1

    Sets the selected item and positions the selection y pixels from the top edge of the ListView. (If in touch mode,      the item will not be selected but it will still be positioned appropriately.)

    译文:设置当前选中的Item,并且定位当前被选中Item的距离y轴的像素值,ListView这个非真正意义上的容器顶部。

    需要注意的是:当前被选中的Item距离y轴的距离:当前被选中Item如果下面有足够长,那么可以满足设置;但是当被选中的Item如果满足了设置,下面的Item占不满屏,就卜会遵从上述规则,而是直接占满屏

 

 

原创粉丝点击