Android creates a new Activity, androidactivity

Source: Internet
Author: User

Android creates a new Activity, androidactivity

This article Reprinted from: http://www.cnblogs.com/wuyudong/p/5658020.html

Create a project, create a java class, and inherit from Activity

Create an Android. xml file: activity_test.xml

Configure the configuration in the configuration file.

<? Xml version = "1.0" encoding = "UTF-8"?> <Manifest xmlns: android = "http://schemas.android.com/apk/res/android" package = "com. wuyudong. newactivity "android: versionCode =" 1 "android: versionName =" 1.0 "> <uses-sdk android: minSdkVersion =" 8 "android: targetSdkVersion =" 17 "/> <! -- Represents the current application --> <application android: allowBackup = "true" android: icon = "@ drawable/ic_launcher" android: label = "@ string/app_name" android: theme = "@ style/AppTheme"> <activity android: name = "com. wuyudong. newactivity. mainActivity "android: label =" @ string/app_name "> <intent-filter> <action android: name =" android. intent. action. MAIN "/> <category android: name =" android. intent. category. LAUNCHER "/> </intent-fi Lter> </activity> <! -- Configure TestActivity --> <activity android: name = "com. wuyudong. newactivity. testActivity "android: label =" @ string/app_name "> <intent-filter> <action android: name =" android. intent. action. MAIN "/> <category android: name =" android. intent. category. DEFAULT "/> </intent-filter> </activity> </application> </manifest>

The code in TestActivity. java is as follows:

Package com. wuyudong. newactivity; import android. app. activity; import android. OS. bundle;/*** create a new Activity * @ author wuyudong **/public class TestActivity extends Activity {/*** Called when the activity is starting. * // @ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // load a layout setContentView (R. layout. activity_test );}}

Summary:

(1) This configuration is required if you want your Activity to have multiple startup icons

            <intent-filter>                <action android:name="android.intent.action.MAIN" />                <category android:name="android.intent.category.LAUNCHER" />            </intent-filter>

(2) the icon and label under the Activity node can be different from the icon and label of the Application node.

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.