で 9 つのButto
n ビューを作成し、main.xml
それに名前を付けてからButton1, Button2... Button9..
、コードでボタンの を作成しました。ArrayList
このボタンの配列が私のボタンを保持main.xml
し、main.xml でボタンを取得するという現在の知識では明らかです。 findViewById メソッドを使用する必要があり、基本的には配列をループしてボタンを取得する必要があります
ArrayList<Button> buttons;
int MAXBTN = 9;
for( int i = 0; i < BTN; i++ )
{
// Code here to use the findViewById method to get the button
}
私の問題はR.id.Button1 .. R.id.Button3
、findViewById メソッドに渡す必要があることですが、これをループする必要があります。とにかくfindViewById
whileループでカウンターを渡すことができますか?
お知らせ下さい。