ImageView Force closes my application

Posted by BlueFireLady on Stack Overflow See other posts from Stack Overflow or by BlueFireLady
Published on 2011-01-15T21:47:10Z Indexed on 2011/01/15 21:53 UTC
Read the original article Hit count: 183

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about android

Related posts about imageview