Android 封裝基類
阿新 • • 發佈:2018-12-11
基類 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(); }