Android Development Learning-four components (1)

Source: Internet
Author: User

Activity (i) Create basic activity

1. Activity is a component that contains a user interface that is used primarily for interacting with users.

2, one of the most basic activity creation process

① to create a new empty project

② Create a Mainactivity

③ Create a new layout

④ registered in Androidmanifest, all activities are registered here

⑤ specify an activity as the primary activity

<activity
Android:name= ". Mainactivity "
Android:label= "@string/title_activity_main"
Android:theme= "@style/apptheme.noactionbar" >
<intent-filter>
<action android:name= "Android.intent.action.MAIN"/>
<category android:name= "Android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>

3, one of the most basic activity completed

(ii) Life cycle of activity

1, Oncreate-->onstart-->onresume-->onpause-->onstop-->ondestroy

2. The complete life cycle of an activity consists of six steps above, when the activity is visible at OnPause, when it returns to the top of the stack, returning to Onresume, when it is killed because of memory tension, start the activity again from OnCreate

3, the activity is in OnStop, is in the invisible State, when it is killed because of memory tension, start the activity again from OnCreate, when it returns to the top of the stack, call Onrestart back to OnStart

Android Development Learning-four components (1)

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.