【发布时间】:2018-11-12 07:31:32
【问题描述】:
我在我的 xml 中定义了一个 TableLayout,其中包含三列四行加上一个标题行。 每列包含一个 TextView。
<TableLayout
android:id="@+id/inventory"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="*"
<TableRow>
<TextView
android:text="Item"/>
<TextView
android:text="Quantity"/>
<TextView
android:text="Units"/>
</TableRow>
<TableRow>
<TextView
android:id="@+id/inventorycell10"
<TextView
android:id="@+id/inventorycell11"
<TextView
android:id="@+id/inventorycell12"
</TableRow>
<TableRow>
<TextView
android:id="@+id/inventorycell20"
<TextView
android:id="@+id/inventorycell21"
<TextView
android:id="@+id/inventorycell22"
</TableRow>
<TableRow>
<TextView
android:id="@+id/inventorycell30"
<TextView
android:id="@+id/inventorycell31"
<TextView
android:id="@+id/inventorycell32"
</TableRow>
<TableRow>
<TextView
android:id="@+id/inventorycell40"
<TextView
android:id="@+id/inventorycell41"
<TextView
android:id="@+id/inventorycell42"
</TableRow>
</TableLayout>
有没有办法在代码中引用 TextViews,而不必单独标识它们。我在想可能有办法从表格视图中获取行/列视图。
-弗林克
【问题讨论】:
标签: android