什么是Android ListView的起始索引(位置),0或1

时间:2014-05-29 07:45:34

标签: android android-listview

萨拉姆
简单问题:什么是Android ListView的起始索引(位置),0或1

list.getChildAt(index);

1 个答案:

答案 0 :(得分:4)

注意:第一个索引始终以0开头。

因此list.getChildAt(index)将返回索引0处的第一个子节点,索引1处的下一个子节点,依此类推。

但是,根据您的开始循环,您可以从任何方式获取以获取任何子项,

for(int i = 0;i< listview.size();i++)
{
  //you get the first child as starting point in a loop
  list.getChildAt(index); //the start index is 0 here.
}

for(int i = 1;i< listview.size();i++)
{
  //you get the second child as starting point in a loop
  list.getChildAt(index); //the start index is 1 here.
}

public View getChildAt(int index)

在API级别1中添加

返回组中指定位置的视图。

<强>参数

索引 获取视图的位置

<强>返回

  • 指定位置的视图;如果组中的位置不存在,则为null