ImageView Force closes my application
- by BlueFireLady
Hi there I am really a beginner, and I have been fighting with this problem for 3 days. :(
I am able to get an image to show using a grid view and an adapter as in the grid view tutorial, but I wanted to be able to just use ImageView in the xml.
public class HelloImage extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView gridview = (ImageView) findViewById(R.id.gridview);
gridview.setLayoutParams(new GridView.LayoutParams(85, 85));
gridview.setScaleType(ImageView.ScaleType.CENTER_CROP);
gridview.setPadding(8, 8, 8, 8);
gridview.setImageResource(R.drawable.hand_tool);
}
}
When I run this it causes the app to force close when loading.