我幾天前開始學習java,所以我很迷茫。 我想顯示從意圖收到的文本,並使其看起來像這樣: 「你寫過:」。 它根本不工作,我只能從意圖中顯示文字。Java/Android的基本問題
這裏是我的代碼:
// Create the text view
TextView textView = new TextView(this);
textView.setTextSize(40);
System.out.print("You've written: ");
textView.setText(message);
System.out.print(".");
// Set the text view as the activity layout
setContentView(textView);
}
此外,我想顯示在頁面(或儘可能多的行需要)的第一行上面寫的文字,底下的標籤插入一個文本連同一個按鈕。問題是我只能從意圖中看到文字。 這裏是我的代碼:
<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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".DisplayMessageActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage"/>
</RelativeLayout>
三江源非常多,我想我會很快回答。
您正在使用RelativeLayout但沒有放置結構。它們將在視圖的左上角彼此重疊。 – DeeV 2013-03-26 14:38:15