Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a PNG file to an ImageView?

I have a file called nochart.png in /drawable.

How can I set this to an ImageView?

chartImageView.setImageDrawable(R.drawable.nochart);

Does not compile.

like image 932
Sheehan Alam Avatar asked Sep 29 '10 02:09

Sheehan Alam


2 Answers

just put your .png file in mipmap folder

like image 92
Rachit Vohera Avatar answered Sep 19 '22 20:09

Rachit Vohera


Use:

chartImageView.setImageResource(R.drawable.nochart);
like image 24
skorulis Avatar answered Sep 19 '22 20:09

skorulis