“如何简洁地实现可编辑的表格布局”

时间:2018-02-22 15:57:59

标签: android xml layout android-tablelayout

我是Android的新手,我正在尝试为项目获取此特定布局,但我想知道是否有更简单的方法,我已经添加了.xml文件的代码以及图像我想要的布局。我也进行了大量的查询搜索,但是大部分搜索结果都是一个涉及MYSQL的解决方案,对于像我这样的初学者来说,这似乎真的很吓人......

enter image description here

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.ruturaj.myapplication.MainActivity">


<EditText
    android:id="@+id/editText00"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText01"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText02"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText03"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText04"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText05"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText06"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText10"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText11"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText12"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText13"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText14"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText15"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText16"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.229" />

<EditText
    android:id="@+id/editText20"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText21"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText22"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText23"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText24"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText25"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText26"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.524" />

<EditText
    android:id="@+id/editText30"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText31"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText32"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText33"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText34"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText35"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText36"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.451" />

<EditText
    android:id="@+id/editText40"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText41"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText42"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText43"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText44"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText45"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText46"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.377" />

<EditText
    android:id="@+id/editText50"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="68dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText51"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="24dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText52"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="288dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText53"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="244dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText54"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="200dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText55"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="156dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

<EditText
    android:id="@+id/editText56"
    android:layout_width="47dp"
    android:layout_height="34dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="112dp"
    android:layout_marginTop="8dp"
    android:background="@drawable/back"
    android:ems="10"
    android:inputType="number"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:layout_constraintVertical_bias="0.303" />

3 个答案:

答案 0 :(得分:1)

考虑将RecyclerViewGridLayoutManager一起使用 一开始可能看起来令人生畏,但比看起来容易。 我们的想法是创建一个视图列表作为网格,并使用适配器为它们提供单独的功能。

这是link从哪里开始。

祝你好运

答案 1 :(得分:0)

问题不明确,正如@tehhowch所说,你应该解释更多你想要的东西,以及你尝试过的东西。

但是,您应该尝试使用GridView并使用EditText填充它。 这里也解释了这一点:Create EditText in Gridlayout programmatically in Android,尽管这个示例并不完全符合您的要求,但您可以根据需要轻松更改它,甚至可以实现适配器来处理gridview点击和更改。

  

XML:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/layout_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<GridLayout
    android:id="@+id/inputTasksLayout"
    android:layout_width="fill_parent"
    android:layout_height="0dp"
    android:layout_weight="1"
    android:columnCount="2"
    android:rowCount="10">


</GridLayout>

<Button
    android:id="@+id/addnewTask"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:onClick="addView"
    android:text="Add" />
</LinearLayout>
     

的活动:

public class MainActivity extends AppCompatActivity {
int rowIndex = 1;
int colIndex = 0;
private GridLayout gridLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.inputTasksLayout);
    gridLayout = (GridLayout) findViewById(R.id.gridView);

}

public void addView(View view) {
    EditText editText = new EditText(this);
    GridLayout.LayoutParams param = new GridLayout.LayoutParams();
    param.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    param.width = GridLayout.LayoutParams.MATCH_PARENT;
    param.rowSpec = GridLayout.spec(rowIndex);
    param.columnSpec = GridLayout.spec(colIndex);
    editText.setLayoutParams(param);
    if (rowIndex == 1) {
        editText.setId(R.id.task1);
    }
    if (rowIndex == 2) {
        editText.setId(R.id.task2);
    }

    gridLayout.addView(editText);
    rowIndex++;
 }
}

答案 2 :(得分:0)

我认为你可以使用GridView或RecyclerView来创建表,为此你可以从简单的GridView开始。

本指南:Android GridView Tutorial