有一个带有图像的网格视图和一个用于浏览图库的按钮,以便获取图像。所选图像显示在另一个活动中。显示图像活动具有单个图像视图和三个与图像视图重叠的文本视图。问题是,当我从gridview中选择图像时,它工作正常,图像视图与文本视图一起显示,但是当我从图库中选择图像时,文本视图已经消失。只有图像可见。
还添加了用于显示图像活动的xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/relativeLayout"
tools:context="${packageName}.${activityClass}" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"/>
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="60dp"
android:layout_marginTop="32dp"
/>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView1"
android:layout_marginTop="81dp"
/>
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView1"
android:layout_below="@+id/textView2"
android:layout_marginTop="81dp"
/>
</RelativeLayout>
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_eid_card_final);
Intent intent = getIntent();
String message1 = intent.getStringExtra("RECEIVER");
String message2 = intent.getStringExtra("SENDER");
String message3 = intent.getStringExtra("MESSAGEBODY");
String check_click = intent.getStringExtra("bttnclick");
ImageView imageView = (ImageView) findViewById(R.id.imageView1);
TextView receiver = (TextView) findViewById(R.id.textView1);
TextView sender = (TextView) findViewById(R.id.textView2);
TextView messagebody = (TextView) findViewById(R.id.textView3);
receiver.setText(message1);
sender.setText(message2);
messagebody.setText(message3);
// Selected image id
if ("BUTTONCLICK".equals(check_click)) {
String path = intent.getStringExtra("image");
Uri myUri = Uri.parse(path);
imageView.setImageURI(myUri);
} else {
int position = intent.getExtras().getInt("id");
ImageAdapter imageAdapter = new ImageAdapter(this);
//ImageView imageView = (ImageView) findViewById(R.id.imageView1);
imageView.setImageResource(imageAdapter.thumbIds[position]);
}