Image crashes from application
I am using the Android Sutdio navigation fragment template. I added ImageView to fragment_main.xml file as follows
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/imageView"
android:src="@drawable/at"
android:layout_below="@+id/section_label"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="80dp" />
And the java code looks like this In the OnCreate method.
img = (ImageView)findViewById(R.id.imageView);
In the attached method section.
img.setImageResource(R.drawable.at);
Every time I run this code it crashes. If the image source is set to XML it works very well, but when I use a java file to change the image source. It crashes stating that the "Sorry" application has stopped. Image details, if necessary Image size: 32.3 kb Dimensions: 450 * 432 pixels
See android console log if the source of the error can be found there
Are the crash reports coming from any version of Android and you only have certain resources in qualified folders i.e. "drawable-mdpi" instead of "drawable"? read this http://developer.android.com/guide/topics/resources/providing-resources.html
If you are using Eclipse have you tried cleaning and rebuilding your project? I had a similar problem.
source to share