基类 package com.example.darker.moniti; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; public abstract class BaseActivity extends AppCompatActivity { @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); prieviewAction(); setContentView(getContentView()); initView(); initData(); setLinstener(); setMroeAction(); } protected void prieviewAction(){ }; protected abstract void initView(); protected abstract int getContentView(); protected void initData(){}; protected void setLinstener(){}; protected void setMroeAction() { } }
继承基类
public class MainActivity extends BaseActivity { //两个方法 aly+enter //获取id protected abstract void initView(); //界面 protected abstract int getContentView(); }