Android with return value of the window jump

Source: Internet
Author: User

1, Androidmanifest.xml

<?XML version= "1.0" encoding= "Utf-8"?><Manifestxmlns:android= "Http://schemas.android.com/apk/res/android" Package= "Com.fish.helloworld"Android:versioncode= "1"Android:versionname= "1.0" >    <USES-SDKandroid:minsdkversion= "+"android:targetsdkversion= "+" />    <ApplicationAndroid:allowbackup= "true"Android:icon= "@drawable/ic_launcher"Android:label= "@string/app_name"Android:theme= "@style/apptheme" >        <ActivityAndroid:name=". Receive "Android:label= "@string/title_activity_receive" >             <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>        <ActivityAndroid:name=". Send "Android:label= "@string/title_activity_send" >        </Activity>    </Application></Manifest>

2. Receive

 PackageCom.fish.helloworld;ImportCom.fish.helloworld.Forwarding.backButton_OnClickListener;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;Importandroid.text.Editable;ImportAndroid.view.Menu;ImportAndroid.view.MenuItem;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button;ImportAndroid.widget.TextView; Public classReceiveextendsActivity {PrivateBackbutton_onclicklistener Backbuttonlistener =NewBackbutton_onclicklistener (); PrivateTextView M_textview; Static Final Private intGet_code = 0; classBackbutton_onclicklistenerImplementsonclicklistener{ Public voidOnClick (View v) {Intent Intent=NewIntent (Receive. This, Send.class);                    Startactivityforresult (Intent, Get_code); }} @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.receive_result); FinalButton Backbutton =(Button) Findviewbyid (R.id.button1);                 Backbutton.setonclicklistener (Backbuttonlistener); M_textview=(TextView) Findviewbyid (R.ID.TEXTVIEW1); } @Overrideprotected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {        if(Requestcode = =Get_code) {String text= ""; if(ResultCode = =result_canceled) {Text= "Corkey"; }Else{text= "Violet";        } m_textview.settext (text); }            }    }

3. Send

 PackageCom.fish.helloworld;ImportCom.fish.helloworld.Receive.backButton_OnClickListener;Importandroid.app.Activity;Importandroid.content.Intent;ImportAndroid.os.Bundle;ImportAndroid.view.Menu;ImportAndroid.view.MenuItem;ImportAndroid.view.View;ImportAndroid.view.View.OnClickListener;ImportAndroid.widget.Button; Public classSendextendsActivity {PrivateBackbutton_onclicklistener Backbuttonlistener =NewBackbutton_onclicklistener (); PrivateBackbutton_onclicklistener2 BackButtonListener2 =NewBackbutton_onclicklistener2 (); classBackbutton_onclicklistenerImplementsonclicklistener{ Public voidOnClick (View v) {Setresult (RESULT_OK, (NewIntent (). Setaction ("corkey!")));        Finish (); }    }    classBackbutton_onclicklistener2Implementsonclicklistener{ Public voidOnClick (View v) {Setresult (result_canceled, (NewIntent (). Setaction ("violet!")));        Finish (); }} @Overrideprotected voidonCreate (Bundle savedinstancestate) {Super. OnCreate (savedinstancestate);                Setcontentview (R.layout.send_result); FinalButton Backbutton =(Button) Findviewbyid (R.id.button1);                Backbutton.setonclicklistener (Backbuttonlistener); FinalButton BackButton2 =(Button) Findviewbyid (R.id.button2);    Backbutton2.setonclicklistener (BACKBUTTONLISTENER2); }}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.