English 中文(简体)
单击提交按钮后在另一页中显示窗体数据
原标题:Displaying Form Data in another page after clicking submit button

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.

提前感谢

问题回答

以同样的声调显示它应该起作用...

TextView text = (TextView)findViewById(R.id.TextViewResult);

EditText emailField = (EditText) findViewById(R.id.EditTextEmail);


String email = emailField.getText().toString();  

text.setText(email );

要在其他 active 中显示,您需要将 string 类似 email 通过 >>ent 向另一个 ent 通过 ent 向另一个 活动 ,并在 textview 中同样设定

一 - - - - - - - - - - -

使用此意图将数据发送到另一个 active

Intent i = new Intent(this, ActivityTwo.class);

i.putExtra("Value1", "This value one for ActivityTwo ");

i.putExtra("Value2", "This value two ActivityTwo");

- - - - - - - - - - ―― - ―― - ―― - ―― ―― - ―― ―― ―― ―― - ―― ―― ――

Bundle extras = getIntent().getExtras();
if (extras == null) {
        return;
        }
// Get data via the key
String value1 = extras.getString(Intent.EXTRA_TEXT);
if (value1 != null) {
    // Do something with the data
}

http://www.vogella.com/articles/AndroidIntent/article.html





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签