# # # 1. The overview


Recently there are a lot of people feedback, some elder brothers don’t like to see characters, some elder brothers don’t know what I’m doing, so later I will adopt the way of blogs and video, we can choose to watch video tutorial: http://pan.baidu.com/s/1i5uh2uD

Everyone don’t be fooled by my demo, my mobile phone above there are two connotation of the apK, interface is also the connotation of the interface, interface and material will be sent to you in the source code, but the demo is my own writing. The main point here is that we use our own custom Activity template, the two pages can be developed in minutes

# # # 2. implementation


2.1. What is a custom template? When we create a new project, we can Add an activity to Mobile. At this time, we can choose an activity template. Look at the template I clicked on below. This is my own definition. I have selected my own WelcomeActivity template

So what does our generated code look like? 2.1.1 First – WelcomeActivity

public class WelcomeActivity extends AppCompatActivity {

    private static final long WAIT_TIME = 3000;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);

        // wait for a moment start activity
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                // start activity
                Intent intent = new Intent(WelcomeActivity.this, $HomeActivity.class); startActivity(intent); finish(); } }, WAIT_TIME); }}Copy the code

**2.1.2 ** Resource file – r.layout.activity_welcome

<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:src="@drawable/welcome_image" />
Copy the code

**2.1.3 ** Configuration file – Androidmanifest.xml

<activity
            android:name=".WelcomeActivity"
            android:label="@string/app_name"
            android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
Copy the code

It’s all done. Do I need to write the code? Of course, for example, if you haven’t written the code of the advertisement, we can also write it in, but I don’t care here. Generally, the welcome page is just a picture, wait a few seconds to jump to the main page, and if there are other complicated functions, we are afraid of it if we have the template.

2.2. If you create a new project then you can use it like this, You need to right-click on the package name of the new activity –> New –> Activity. Here I select a Common Activity template. After the new template is created, it will automatically inherit BaseActivity and you can choose whether you need to request data and build headers, etc.

So we have a welcome page and a hot bar page in less than a few minutes, of course, it would be nice to add our custom BaseActivity and custom web engine.

How do we customize the templates ourselves? Please see hereAndroid Studio custom templates are surprisingly easy to develop – post

Attached to the source address: http://download.csdn.net/detail/z240336124/9674377