まだAndroidスタジオが新しく、希望の行と列を持つGridLayoutを作成してEditTextで埋めてテストしたいと思っています。しかし、私はEditTextコンストラクタのパラメータとして何を置くべきかわからない問題に遭遇します。ここで は、以下のJavaコードです:Android StudioのEditTextコンストラクタのパラメータには何を入れる必要がありますか?
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//The numbers WILL vary but this is just a test
int rows = 3;
int columns = 4;
GridLayout gd = (GridLayout) findViewById(R.id.grid1);
gd.setRowCount(rows);
gd.setColumnCount(columns);
EditText edt;
for(int r = 0; r < rows; r++)
{
for(int c = 0; c < columns; c++)
{
//What to put in the parameters in this code below?
edt = new EditText();
gd.addView(edt);
}
}
}
そして、ここではXMLです:
<GridLayout
android:id="@+id/grid1"
android:layout_width="368dp"
android:layout_height="495dp"
tools:layout_editor_absoluteX="8dp"
tools:layout_editor_absoluteY="8dp">
</GridLayout>
私はのEditTextのコンストラクタを見て、そのコンテキストが必要とされて見つけることが、どのように私は、中にいることを置けばいいのそこ?これが正しい方法でない場合は、正しい方法を教えてください。
ありがとうございました!私はそれを忘れていた –