[英]NullPointerException while setting Image in imageView from Bitmap?
I am Using APK Expansion File from http://developer.android.com/guide/market/expansion-files.html 我正在使用http://developer.android.com/guide/market/expansion-files.html上的 APK扩展文件
CODE : 代码:
String[] path= getAPKExpansionFiles(this,2,0);
ZipResourceFile expansionFile;
try {
expansionFile = new ZipResourceFile(path[0]);
InputStream fileStream = expansionFile.getInputStream("assets/Tablet/Chester_the_cat/chester_the_cat_2.png");
Bitmap bit=BitmapFactory.decodeStream(fileStream);
iv_new=(ImageView)findViewById(R.id.iv_new);
iv_new.setImageBitmap(bit);
and m getting this NullPointerException in this line 并在此行中获取此NullPointerException
iv_new.setImageBitmap(bit);
and in XML my ImageView is : 在XML中,我的ImageView是:
<ImageView android:id="@+id/iv_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
您是否使用包含ImageView的布局调用了setContentView(View)
?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.