How to manually create a project in AS

first create ainsert image description here

Manually create events

Manually create an activity
new and an empty activity.
insert image description here
insert image description here
Do not select these two first and then manually adjust them.
The first option is to directly bind a layout.
The second option is to set the currently set activity as the home page

Manually create layouts

insert image description here
insert image description here
insert image description here

Load this layout in activity

Add the following code in the onCreate() method

setContentView(R.layout.activity_main);

Register in the AndroidManifest file

Open the AndroidManifest

 <activity android:name=".FirstActivity"></activity>

Register with the activity tag In general, the AS will automatically register

Register main event

<activity android:name=".MainActivity">
     <intent-filter>
          <actionandroid:name="android.intent.action.MAIN"/>

      <categoryandroid:name="android.intent.category.LAUNCHER"/>
         </intent-filter>
             </activity>

Add the intent-filter tag and two lines of code to the activity tag

Guess you like

Origin blog.csdn.net/weixin_51906150/article/details/114144321