在学习的时候我们觉得建立新的项目很费时间,也费内存,所以我们很多时候都是在一个项目下面创建 多个 activity 来试验
但是如何设置默认首先启动的 Avtivity 来验证我们的新实验是否成功呢?
在 app.src.main 下面有个 Androidmanifest.xml 里面记录了你项目有哪些 activity 当然也记录了那个是默认启动项
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.pro.first">
- <application
- android:allowBackup="true"
- android:icon="@mipmap/ic_launcher"
- android:label="@string/app_name"
- android:supportsRtl="true"
- android:theme="@style/AppTheme">
- <activity android:name=".MainActivity">
- </activity>
- <!--
- ATTENTION: This was auto-generated to add Google Play services to your project for
- App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
- -->
- <meta-data
- android:name="com.google.android.gms.version"
- android:value="@integer/google_play_services_version" />
- <activity android:name=".Main2Activity">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
- </manifest>
我们直接将下面这段代码放在你想默认启动的 activity 中间就行了 就像上面的代码 默认首先启动的是 main2activity
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
来源: http://www.bubuko.com/infodetail-1987470.html