Android ImageView setImageResource in code

后端 未结 5 483
太阳男子
太阳男子 2020-12-13 05:01

I have an imageView that I want to display a little icon of the country that you are currently in. I can get the country code, but problem is I can\'t dynamically change the

5条回答
  •  别那么骄傲
    2020-12-13 05:56

    This is how to set an image into ImageView using the setImageResource() method:

    ImageView myImageView = (ImageView)v.findViewById(R.id.img_play);
    // supossing to have an image called ic_play inside my drawables.
    myImageView.setImageResource(R.drawable.ic_play);
    

提交回复
热议问题