我在从主要活动接收字符串的活动中有以下代码:
String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
TextView textView = new TextView(this);
textView.setTextSize(20);
textView.setText(message);
// Set the text view as the activity layout
setContentView(textView);
我想在下面添加一张图片TextView
:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical" >
<TextView android:layout_alignParentLeft="true"
android:text="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/serious" />
</LinearLayout>
随着线setContentView
,TextView
占据了整个屏幕。没有线,图像显示,但字符串显示“ false
”。任何想法?