Android Studio始めたばかりの未熟者です。
xmlファイルでレイアウトを作った後にスクリプトから取得する際にいい感じに文字列指定で取得することは可能でしょうか?
いちいち指定するのが面倒なので以下のようなことがしたいのです。
xml
1<Button 2 android:id="@+id/Button1" 3 android:layout_weight="1" 4 android:text="button1" /> 5 6<Button 7 android:id="@+id/Button2" 8 android:layout_weight="1" 9 android:text="button2" /> 10 11<Button 12 android:id="@+id/Button3" 13 android:layout_weight="1" 14 android:text="button3" />
java
1for(int i=0; i<3; i++){ 2 button = (Button) dialog.findViewById(R.id.{"Button"+i}); 3//なんか処理 4}
現状だと以下のような手法しかできませんでしたので知恵を貸していただければと
java
1button = (Button) dialog.findViewById(R.id.Button1); 2//なんか処理 3button = (Button) dialog.findViewById(R.id.Button2); 4//なんか処理 5button = (Button) dialog.findViewById(R.id.Button3); 6//なんか処理
よろしくお願いします!

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/03/08 09:40