レイアウトを作成するときは、ビューの ID を次のように定義します。
<ImageView
android:id="@+id/myImage"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/main01" />
そしてあなたのコードには次のものがあります:
ImageView img = (ImageView) findViewById(R.id.myImage);
のオブジェクトができimg
ました。
img
("myImage")の ID を文字列として取得するにはどうすればよいですか? 私はこのようなものが必要です:
String strId = getStringId(img);
// now strId is "myImage"