私はこれを得た :
String input = "image_to_show"
そして私のドローアブルで:
image_to_show.png
私がやります:
imageView.setImageResource(R.drawable.image_to_show);
これは機能し、ドローアブル内のオブジェクトを参照します
コンテキストが drawables オブジェクトと同じ名前の文字列を使用して動作させることはできますか
まず、名前で resId を見つけます
int resId = getResources().getIdentifier(resName, "drawable", getPackageName());
次に、見つかった resId を使用します
imageView.setImageResource(resId);
関連する ID を取得するには、リソースのgetIdentifierメソッドを使用する必要があります。
その ID を取得したら、imageView.setImageResource(R.drawable.image_to_show); を呼び出します。いつものように