Skip to content

Instantly share code, notes, and snippets.


codeforfun-jp/ Secret

Last active Mar 23, 2021
What would you like to do?
【Android Studio】画像名を使って ImageView に画像を表示する方法
// ImageViewの用意
ImageView myImage= findViewById(;
// 画像名
String imageName = "sample";
// 画像のリソースIDを取得
int resId = getResources().getIdentifier(imageName, "drawable", getPackageName());
// ImageViewに画像をセット
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment