我正在使用http://developer.android.com/guide/market/expansion-files.html
中的APK扩展文件代码:
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);
并在此行中获得此NullPointerException
iv_new.setImageBitmap(bit);
在XML中,我的ImageView是:
<ImageView android:id="@+id/iv_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
答案 0 :(得分:2)
您是否使用包含ImageView的布局调用setContentView(View)