我在我的TableLayout中有很多行,我想访问按钮视图。示例如下:子元素的孩子
<TableLayout>
<TableRow>
<Button />
<Button />
</TableRow>
<TableRow>
<Button />
<Button />
</TableRow>
</TableLayout>
从表格布局中,我想通过按钮循环。
TableLayout layout=(TableLayout) findViewById(R.id.Layout);
layout.getChildCount;
以上仅返回数字表行视图。
你会需要一些递归这个 –
你为什么不给ID属性为每个按钮和通过tableLayout.findViewById(R.id.yourButtonId)访问它? – Talha
谢谢,也将很好地工作,因为每个按钮都有一个唯一的ID ... –