-4
//setImageBitmap gives nullPointerException
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inSampleSize = 2;
Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.img, bitmapOptions);
//imageView for referencig imageView of layout file
ImageView imageView=(ImageView)findViewById(R.id.imageView1);
imageView.setImageBitmap(imageBitmap);
//setImageBitmap gives nullPointerException
}catch (Exception e){
e.printStackTrace();
}
//setContentView(imageView);
setContentView(R.layout.activity_main);
}
}