ในโปรเจ็กต์ Android ของฉัน ฉันมี imageButton และหลังจากคลิกแล้ว มันจะต้องเปิด Activity ใหม่ด้วย imageView และใน Activity ใหม่ของฉัน ฉันต้องเห็นรูปภาพของ ImageButton ในรูปแบบขนาดใหญ่เท่านั้น ขนาดรูปภาพของฉันคือ 17mb และฉันก็มีหน่วยความจำไม่เพียงพอ ข้อผิดพลาด. แต่โค้ดของฉันใช้ได้กับรูปภาพที่มีขนาดน้อย ใครสามารถช่วยปรับขนาดภาพหรือเปลี่ยนตัวเลือกบิตแมปหรือคำแนะนำอื่นได้บ้าง ฉันใหม่ใน Android และขออภัยสำหรับภาษาอังกฤษที่ไม่ดี :)
นี่คือ XML ของกิจกรรมใหม่ของฉัน
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:id="@+id/LL11"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Here must be an image">
</TextView>
<ImageView
android:id="@+id/imageView1"
android:maxWidth="10px"
android:maxHeight="10px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_action_search" />
</LinearLayout>
และโค้ดจาวา
package com.example.example;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
package com.example.example;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.ImageView;
public class ActivityTwo extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.custom_dialog);
Bundle extras = getIntent().getExtras();
String path = extras.getString("path");
if(null != path)
{
Uri myUri = Uri.parse(path);
super.onCreate(savedInstanceState);
ImageView img1 = (ImageView) findViewById(R.id.imageView1);
img1.setImageURI(myUri);
}
}
}