Create your own activity

Source: Internet
Author: User

Create your own activity

1. New class, Inherit activity class

2. Overriding the OnCreate method of a new class
 Public class extends Activity {    publicvoid  onCreate (Bundle saveinstancestate) {        super  . OnCreate (saveinstancestate);        Setcontentview (r.layout.second_layout);    // To reference the layout file, first build the file, see below
}
3. Create a new layout file

4. Add a description in Androidmainfest.xml (must be in application)

The Intent-filter in the first activity description is the description statement as the first start page

<ActivityAndroid:name=". Firstactivity "Android:label= "Activity created by yourself">            <Intent-filter>                <ActionAndroid:name= "Android.intent.action.MAIN" />                <categoryAndroid:name= "Android.intent.category.LAUNCHER" />            </Intent-filter>        </Activity>        <ActivityAndroid:name=". Secondactivity "Android:label= "This is a second activity"/>


Create complete, detect references successfully by CTRL + Mouse

Create your own activity

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.