Can't display image with Imageview on Android
- by user1029167
In my \drawable-mdpi folder, I have an image named: test.jpg
In my main.xml file, in my LinearLayout section, I have:
<ImageView
android:id="@+id/test_image"
android:src="@drawable/test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
In my src folder, I have only 1 file, HelloAndroidActivity.java with only the following method:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView image = new ImageView(this);
image = (ImageView) findViewById(R.id.test_image);
setContentView(image);
}
This seems to be correct, yet whenever I try to run it, I get The application HelloAndroid (process xxxxx) has stopped unexpectedly. Please try again.
The strange part is it previously did display the image, but now it won't and I don't know why.
Also, when I comment out the ImageDisplay code, and replace it with TextDisplay code. i.e.
TextView tv = new TextView(this);
tv.setText("Does this work?");
setContentView(tv);
It does display the text.
Edit: was asked to post logcat. Link to pastebin.