Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Android开发中,您将如何绘制矩阵?_Java_Android - Fatal编程技术网

Java 在Android开发中,您将如何绘制矩阵?

Java 在Android开发中,您将如何绘制矩阵?,java,android,Java,Android,矩阵的大小将由用户使用变量h、w输入 鉴于此,我如何在屏幕上创建该大小的矩阵,允许用户在矩阵中输入值。可能通过在a中生成a来尝试使用and 我没有使用它们,但我猜您的活动代码如下所示: public void onCreate(Bundle b) { TableLayout table = new TableLayout(this); for (int i = 0; i < rows; i++) { TableRow row = new TableRow(t

矩阵的大小将由用户使用变量h、w输入

鉴于此,我如何在屏幕上创建该大小的矩阵,允许用户在矩阵中输入值。

可能通过在a中生成a来尝试使用and

我没有使用它们,但我猜您的活动代码如下所示:

public void onCreate(Bundle b) {
    TableLayout table = new TableLayout(this);
    for (int i = 0; i < rows; i++) {
        TableRow row = new TableRow(this);
        for (int j = 0; j < columns; j++) {
            EditText cell = new EditText(this);
            cell.setText("(" + i + ", " + j + ")");
            row.add(cell);
        }
        table.add(row);
    }
    setContentView(table);
}
public void onCreate(Bundle b){
TableLayout table=新的TableLayout(本);
对于(int i=0;i}
上面的代码不太管用,但差不多就在那里了。我必须更改addView的添加

import android.widget.TableRow.LayoutParams;
import android.widget.TableRow;
import android.widget.EditText;
import android.widget.TableLayout;

public void onCreate(Bundle b) {
    TableLayout table = new TableLayout(this);
    for (int i = 0; i < rows; i++) {
        TableRow row = new TableRow(this);
        for (int j = 0; j < columns; j++) {
            EditText cell = new EditText(this);
            cell.setText("(" + i + ", " + j + ")");
            row.addView(cell);
        }
        table.addView(row new TableLayout.LayoutParams(
                LayoutParams.FILL_PARENT,
                LayoutParams.WRAP_CONTENT)););
    }
    setContentView(table);
}
导入android.widget.TableRow.LayoutParams;
导入android.widget.TableRow;
导入android.widget.EditText;
导入android.widget.TableLayout;
创建时的公共void(Bundle b){
TableLayout table=新的TableLayout(本);
对于(int i=0;i