Use of Android development note ___intent

Source: Internet
Author: User

1  Public classActrequestactivityextendsAppcompatactivityImplementsOnclicklistener {2 3     PrivateEditText et_request;4     PrivateTextView tv_request;5 6 @Override7     protected voidonCreate (Bundle savedinstancestate) {8         Super. OnCreate (savedinstancestate);9 Setcontentview (r.layout.activity_act_request);TenFindviewbyid (r.id.btn_act_request). Setonclicklistener ( This); OneEt_request =(EditText) Findviewbyid (r.id.et_request); ATv_request =(TextView) Findviewbyid (r.id.tv_request); -     } -  the @Override -      Public voidOnClick (View v) { -         if(V.getid () = =r.id.btn_act_request) { -Intent Intent =NewIntent (); +Intent.setclass ( This, Actresponseactivity.class); -Intent.putextra ("Request_time", Dateutil.getnowtime ()); +Intent.putextra ("Request_content", Et_request.gettext (). toString ()); AStartactivityforresult (Intent, 0); at         } -     } -  - @Override -     protected voidOnactivityresult (intRequestcode,intResultCode, Intent data) { -         if(Data! =NULL) { inString response_time = Data.getstringextra ("Response_time"); -String response_content = Data.getstringextra ("Response_content"); toString desc = String.Format ("received return message: \ n response time is%s\n answer content is%s", + Response_time, response_content); - Tv_request.settext (DESC); the         } *     } $ Panax Notoginseng}

1  Public classActresponseactivityextendsAppcompatactivityImplementsOnclicklistener {2 3     PrivateEditText Et_response;4     PrivateTextView Tv_response;5 6 @Override7     protected voidonCreate (Bundle savedinstancestate) {8         Super. OnCreate (savedinstancestate);9 Setcontentview (r.layout.activity_act_response);TenFindviewbyid (R.id.btn_act_response). Setonclicklistener ( This); OneEt_response =(EditText) Findviewbyid (r.id.et_response); ATv_response =(TextView) Findviewbyid (r.id.tv_response); -          -Bundle bundle =getintent (). Getextras (); theString request_time = bundle.getstring ("Request_time"); -String request_content = bundle.getstring ("Request_content"); -String desc = String.Format ("received request message: \ n Request time is%s\n request content is%s", - Request_time, request_content); + Tv_response.settext (DESC); -     } +  A @Override at      Public voidOnClick (View v) { -         if(V.getid () = =r.id.btn_act_response) { -Intent Intent =NewIntent (); -Bundle bundle =NewBundle (); -Bundle.putstring ("Response_time", Dateutil.getnowtime ()); -Bundle.putstring ("Response_content", Et_response.gettext (). toString ()); in Intent.putextras (bundle); - Setresult (ACTIVITY.RESULT_OK, intent); to finish (); +         } -     } the  *}

Use of Android development note ___intent

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.