i 是一个非常新鲜的机器人, i 已创建了一个有 3 字段的窗体 。 我想在下一个屏幕或文本View 中在同一屏幕中显示这些字段数据, 但是我失败了... 以下是 xml 代码 。
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/TextViewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/feedbacktitle"
android:textSize="10pt">
</TextView>
<EditText
android:id="@+id/EditTextName"
android:layout_height="wrap_content"
android:hint="@string/feedbackname"
android:inputType="textPersonName"
android:layout_width="fill_parent">
</EditText>
<EditText
android:id="@+id/EditTextEmail"
android:layout_height="wrap_content"
android:hint="@string/feedbackemail"
android:inputType="textEmailAddress"
android:layout_width="fill_parent">
</EditText>
<EditText
android:id="@+id/EditTextFeedbackBody"
android:layout_height="wrap_content"
android:hint="@string/feedbackbody"
android:inputType="textMultiLine"
android:lines="5"
android:layout_width="fill_parent">
</EditText>
<Button
android:id="@+id/ButtonSendFeedback"
android:layout_height="wrap_content"
android:text="@string/feedbackbutton"
android:onClick="sendfeedback"
android:layout_width="fill_parent">
</Button>
<TextView
android:id="@+id/TextViewResult"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10pt">
</TextView>
</LinearLayout>
</ScrollView>
活动类代码
package com.Delegence.FormHandling;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class FormHandlingActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
TextView Text = (TextView)findViewById(R.id.TextViewResult);
public void sendFeedback(View button) {
EditText nameField = (EditText) findViewById(R.id.EditTextName);
String name = nameField.getText().toString();
EditText emailField = (EditText) findViewById(R.id.EditTextEmail);
String email = emailField.getText().toString();
EditText feedbackField = (EditText) findViewById(R.id.EditTextFeedbackBody);
String feedback = feedbackField.getText().toString();
Text.setText(name);
}
} please guide me how to see these form field value.
提前感谢