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.