Android studio androidstudio中的动态表
我需要帮助在android studio中创建一个表,请查看我的代码并帮助我…当我想在我的设备中运行它时,此代码有错误Android studio androidstudio中的动态表,android-studio,Android Studio,我需要帮助在android studio中创建一个表,请查看我的代码并帮助我…当我想在我的设备中运行它时,此代码有错误 TableLayout table=new TableLayout(this); public void _start(View v) { CreateTable(); } public void CreateTable() { for (int row = 0; row < 3; row++) { TableRow groupCells
TableLayout table=new TableLayout(this);
public void _start(View v) {
CreateTable();
}
public void CreateTable() {
for (int row = 0; row < 3; row++) {
TableRow groupCells = new TableRow(this);
for(int column=0;column<3;column++) {
TextView cell = CreateCells(row, column);
groupCells.addView(cell);
}
table.addView(groupCells);
}
}
private TextView CreateCells(int row, int column) {
TextView cell = new TextView(this);
cell.setId(Integer.valueOf(row + "," + column));
cell.setWidth(20);
cell.setHeight(20);
cell.setText("");
cell.setX((findViewById(R.id._table).getWidth()/2)-(20*row)+(cell.getWidth()/2));
cell.setY((findViewById(R.id._table).getHeight()/2)-(20*column)+(cell.getHeight()/2));
cell.setVisibility(View.VISIBLE);
return cell;
}
TableLayout table=新的TableLayout(此);
公共作废_开始(视图五){
CreateTable();
}
公共void CreateTable(){
对于(int行=0;行<3;行++){
TableRow groupCells=新的TableRow(此);
对于(int column=0;column请发布错误。:@Bob当我运行它时,我的设备会给我强制停止错误