简体   繁体   中英

How can I get the R.drawable.image_sample under ImageView -> LinearLayout android?

How can I get the R.drawable.image_sample under ImageView -> LinearLayout?

I want to get the image under specific LinearLayout but I don't have an idea on how to this.

LinearLayout -> ImageView -> R.drawable.image_sample

Thanks in advance.

ImageView myImageView = (ImageView) findViewById(R.id.your_image_view_id_you_have_set_in_your_xml_layout);

Get the instance of the ImageView and use the method described below on that instance.

http://developer.android.com/reference/android/widget/ImageView.html#setImageResource(int)

       you just need to use
       android:background="@drawable/image_sample" 
       in imageview 

or

              you can use 
              android:src="@drawable/image_sample"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM