Android-activity Use (2)

Source: Internet
Author: User

Then android-activity use (1) to achieve page jump

One. Add a button to the main_activity, note that the ID is written as "@+id/" + "ID real name"

<Button android:layout_width="Wrap_content " android:layout_height=  "wrap_content"  Android:text=start_aty1  " Android:id=" @+id/btnstartaty1 " Android:layout_below= "@+id/tvout"  Android : Layout_alignparentstart= "true             

Two. Implementing a jump in Mainactivity.java

PrivateButton btnSatrtAty1; @Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);        Setcontentview (R.layout.activity_main); //must be placed after the Setcontentview .btnsatrtaty1=(Button) Findviewbyid (r.id.btnstartaty1); //set the event listener for the buttonBtnsatrtaty1.setonclicklistener (//an anonymous class that implements the Onclicklistener interface            NewView.onclicklistener () {@Override Public voidOnClick (view view) {//event to start the Aty1//parameter One: examples of mainactivity//parameter two: The class of the activity to be started is defined as type class//This refers to the inner class that implements the OnclicklistenerIntent i=NewIntent (mainactivity. This, Aty1.class);                StartActivity (i); }        });    }

Third, the realization of the closure of the page

Directly call method Finish ();

Android-activity Use (2)

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.