I want to change the drawable of imageview, that is saved to disk,, and is available. but when setting drawable, a NullPointerException occurs
The question is, how to change imageview drawable of inflated layout[Source image is "/sdcard/myappfolder/user.png"], the layout is inflated
Here's my part of code:
intilt = itilt.inflate(R.layout.pic_container, null, false); //layout is inflated successfully
picCheck(); // method to check file availability, working perfect, if file exists, returns 1, else returns 0;
if(picmark == 1){
Bitmap pch = BitmapFactory.decodeFile(file.getAbsolutePath());
imageView = (ImageView)findViewById(R.id.contimg); //contimg is ImageView id from layout pic_container
imageView.setImageBitmap(pch);
/**
* Caused by: java.lang.NullPointerException
* at com.package.packagename.javaact.onCreate(javaact.java:83)
*/
}
else{
Toast.makeText(this, "File Not Found, setting Default", Toast.LENGTH_SHORT).show();
}
Try like this:
imageView = (ImageView) intilt .findViewById(R.id.contimg);