【问题标题】:Android LinearLayout getChildAt(index) [duplicate]Android LinearLayout getChildAt(index) [重复]
【发布时间】:2013-04-29 10:54:28
【问题描述】:

LinearLayout getChildAt(index) 方法总是返回子视图的第 0 个位置。如何通过getChildAt(index) 在我的LinearLayout 中获得剩余的子视图。

任何帮助。谢谢

【问题讨论】:

  • 您只使用了线性布局或任何列表视图。
  • 你为什么不发布你的代码。
  • 只有线性布局。它有 4 个子视图。我正在尝试访问所有子视图。但该方法仅返回第 0 个位置的子视图
  • 试试我的答案,看看有什么好处..

标签: android android-layout android-linearlayout


【解决方案1】:

也许对你有帮助。

ll 是你的线性布局。

int childcount = ll.getChildCount();
for (int i=0; i < childcount; i++){
      View v = ll.getChildAt(i);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-16
    • 2017-01-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多