First, no return value
Jump page, and the first page of the EditText input data through the button to the second page edittext display, click on the second page of the
Return button buttons to return to the first page (changing the contents of the second page of EditText cannot be returned to the first page)
--normal way, no way to return a value
1. Set the ID for the first page edittext and button
2. Set button's click-Listen
(1) Get the view instance and find the EditText by EditText ID
(2) Get the content and convert it into textual form
GetText (). ToString ()
(3) Set Intent (intent) to tell the second page, I'm going to jump
Intent in = new Intent (this,excise2.class);
(4) At the same time, the input text content is stored and passed through intent.
In.putextra ("Myet", str);
(5) Start jump
StartActivity (in);
3. Accept the page with EditText receive
(1) Set ID to accept page edittext and button
(2) Create a second page
public class Excise2 extends Activity {
@Override
protected void OnCreate (Bundle savedinstancestate) {
Super.oncreate (savedinstancestate);
Setcontentview (R.LAYOUT.EXCISE2);
(3) Receiving intent intent get
Intent in = Getintent ();
(4) Take the data that is stored get get
String str = In.getextras (). getString ("Myet");
(5) Display data
Manipulating View Instances
EditText mytv= (EditText) Findviewbyid (R.id.jieshouzhi);
Restores the contents of the input box (set) set
Mytv.settext (str);
4. Set the button's tap to listen
Finish ();
Excise1.xml
<EditTextAndroid:layout_width= "200DP"Android:layout_height= "Wrap_content"android:textsize= "40DP"Android:id= "@+id/ett" /> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Pass value to third page"android:textsize= "40DP"Android:id= "@+id/chuanzhi"Android:layout_margintop= "100DP"Android:onclick= "Clickcz" />
Excise1.java
Public voidClickcz (view view) {//toast static methods are called directly with the class name and do not need to be instantiated//Build A Toast Method instance method call method chainToast.maketext ( This, "This is triggered by mouse click monitoring", Toast.length_long). Show (); //get the information you want to pass//Get View instanceEditText ett =(EditText) Findviewbyid (R.id.ett); //Get contentString str =Ett.gettext (). toString (); //Jump Diversion IntentIntent in =NewIntent ( This, Excise2.class); //Store content via intent//The Extra extension is actually a hashmap, and the limit PutExtra is a bundleIn.putextra ("Myet", str); //start jump no return value of the notationstartactivity (in);
Excise2.xml
<EditTextAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:text= "Excise2 third page"android:textsize= "40DP"Android:id= "@+id/jieshouzhi" /> <ButtonAndroid:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"Android:layout_margintop= "150DP"Android:text= "Back"android:textsize= "40DP"Android:id= "@+id/clickec3"Android:onclick= "CLICKEC3" />
Excise2.java
Public classExcise2extendsActivity {@Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate); Setcontentview (R.LAYOUT.EXCISE2); //Receive Information//1. Acceptance of the intention to pass overIntent in = getintent (); //2. Fetching DataString str = in.Getextras (). getString("Myet"); //3. Where is the display//Manipulating View InstancesEditText mytv=(EditText) Findviewbyid (R.id.jieshouzhi); //restores the contents of the input box (set) SetMytv.settext (str); } Public voidClickec4 (View v) {//Closefinish (); }}
android--Return of activity jumps (no return value and return value)--No return value