BCK*_*BCK 1 android rows dynamic tablelayout
我正在TableLayout动态添加行,每行都有多个行TextView.
我想循环我的每一行,我TableLayout想更新一些行(不是每一行),例如TextView我的行中的文本.我该怎么办呢?
循环遍历TableLayout的子项,它们应该是TableRows(或其他布局) - 跳过您不想更新的那些.循环或findViewById将是您的TextViews的TableRow(或其他)的子项
将TextView/CheckBox添加到TableRow时,可以使用setId(R.id.id_of_the_view)设置View的id(您可能希望将其添加到res/values/ids.xml文件中).
然后像这样循环:
TableLayout tableLayout = null;
for(int n = 0, s = tableLayout.getChildCount(); n < s; ++n) {
TableRow row = (TableRow)tableLayout.getChildAt(n);
TextView name = (TextView)row.findViewById(R.id.tv_name);
}
Run Code Online (Sandbox Code Playgroud)
因为你正在使用row.findViewById,所以你正在寻找特定行中的特定id.
| 归档时间: |
|
| 查看次数: |
5187 次 |
| 最近记录: |