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.
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.
Use:
chartImageView.setImageResource(R.drawable.nochart);
android:background="@drawable/image_name"
–
Devoir you can also set the image using an xml file with the following attriblute
android:src="@drawable/nochart"
.jpeg
file. It crashes with a .png
file. –
Devoir android:background="@drawable/image_name"
as a .png
file. –
Devoir I encountered the same problem. The solution for me was to move the ".png" from "drawable-21" to "drawable".
© 2022 - 2024 — McMap. All rights reserved.
.png
file. If I try the same thing with a.jpeg
file, it works. The same is true (i.e crash) if I tryandroid:background="@drawable/image_name"
with a.png
file, but works with.jpeg
s. Any ideas? – Devoir