Android でボタンの配列を作成する方法がわかりません。
これは私が試したコードですが、java.lang.NullPointerException が発生しています。
private Button[] button = {(Button) findViewById(R.id.cGuess1),
(Button) findViewById(R.id.cGuess2),(Button)
findViewById(R.id.cGuess3),(Button) findViewById(R.id.cGuess4)};
これは可能ですか?
編集:
ごめんなさい。間違いに気づきました!
クラス全体の配列を宣言しようとしていて、onCreate の前に ID からビューを取得しようとしていたため、setContentView(R.layout.game); はありませんでした。
ごめん。