我想在全屏显示带有意图的imageButton。我在一个活动中有这个代码:
String[] columns = { MediaColumns.DATA, BaseColumns._ID, MediaColumns.DISPLAY_NAME,
ImageColumns.DESCRIPTION, ImageColumns.LATITUDE, ImageColumns.LONGITUDE };
cursor = managedQuery(Media.EXTERNAL_CONTENT_URI, columns, null, null,
null);
fileColumn = cursor.getColumnIndexOrThrow(MediaColumns.DATA);
imageButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
imageFilePath = cursor.getString(fileColumn);
Intent intent3 = new Intent();
intent3.setClass(Gallery.this, FullScreen.class);
intent3.putExtra("imageFilePath", imageFilePath);
startActivity(intent3);
}
});
这是第二项活动:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.fullscreen);
imageView = (ImageView) findViewById(R.id.ImageView);
Bundle extras = getIntent().getExtras();
String imageFilePath = extras.getString("imageFilePath");
bmp = getBitmap(imageFilePath);
imageView.setImageBitmap(bmp);
}
private Bitmap getBitmap(String imageFilePath) {
BitmapFactory.Options bmpFactoryOptions = new BitmapFactory.Options();
bmpFactoryOptions.inJustDecodeBounds = false;
bmp = BitmapFactory.decodeFile(imageFilePath, bmpFactoryOptions);
return bmp;
}
但是当我点击ImageButton以在全屏模式下看到这个图像时它一直崩溃...任何人都知道任何一段代码或任何程序来做到这一点?谢谢!
LogCat说下一个:
致命的例外:主要
java.lang.OutOfMemoryError:位图大小超过VM预算(堆大小= 5763KB,分配= 2805KB,位图大小= 487KB)
在android.graphics.BitmapFactory.nativeDecodeFile(原生方法)
在android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:355)
at com.geotagging.FullScreen.getBitmap(FullScreen.java:51)
at com.geotagging.FullScreen.onCreate(FullScreen.java:42)
在android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
在android.app.ActivityThread.access $ 1500(ActivityThread.java:132)
在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1033)
在android.os.Handler.dispatchMessage(Handler.java:99)
在android.os.Looper.loop(Looper.java:143)
在android.app.ActivityThread.main(ActivityThread.java:4196)
at java.lang.reflect.Method.invokeNative(Native Method)
在java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
at dalvik.system.NativeStart.main(Native Method)