0
我遇到了Gomoku程序的問題(在10x10板上連續5次)。我試圖從我的Game.java實現一個10x10數組按鈕到我的game.xml。下面是代碼我現在有將java按鈕添加到LinearLayout
public class Game extends Activity implements View.OnClickListener{
private boolean p2Turn = false;
private char board[][] = new char[10][10];
Context c;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.game);
Button btn[][] = new Button[10][10];
for(int i = 0; i<10; i++){
for(int j = 0; j<10; j++){
btn [i][j] = new Button(this);
}
}
}
}
但是我不知道如何將10×10陣列的按鈕來實現我的game.xml
幫助將是巨大的:d
你的代碼有什麼問題? – Kon
按鈕陣列不顯示 –
你會想看看這個:http://stackoverflow.com/questions/4907609/add-button-to-a-layout-programmatically – Kon