我正在研究android项目。我需要创建一些如下图所示的字段。
这里我只显示 4 列,但我有 8 到 10 列。在一种方式中,我可以动态生成编辑文本。如何在 android 屏幕中创建这些字段?
我正在研究android项目。我需要创建一些如下图所示的字段。
这里我只显示 4 列,但我有 8 到 10 列。在一种方式中,我可以动态生成编辑文本。如何在 android 屏幕中创建这些字段?
您可以使用 4 个 EditTexts 作为表的行来制作 ListView。ListView 将自动生成行数。
您好,您可以使用 TableLayout、TextView 和 EditText,如下所示
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Location"
android:layout_weight="1"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Name"
android:layout_weight="1"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Age"
android:layout_weight="1"/>
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Gender"
android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="1"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="2"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="3"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="4"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
<TextView android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="5"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
<EditText android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"/>
</TableRow>
</TableLayout>
</LinearLayout>