所以,我开始用设计模式编写应用程序。我被困在两者之间。如果我犯了什么愚蠢的错误,请原谅。
我从创建一个基本活动开始,
BaseAppCompatActivity:

public abstract class BaseAppCompatActivity extends AppCompatActivity {

    private ProgressDialog mProgressDialog;
    private Toolbar mToolbar;
    private TabLayout mTabLayout;

    private boolean hasToolBar;
    private boolean hasTabLayout;

    @Override
    public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
        setContentView(getLayoutResource());
        initiateViews();
        initToolBar();
        initTabLayout();
    }

    public abstract int getLayoutResource();

    protected abstract void initiateViews();

    public void setHasToolBar(boolean hasToolBar){
        this.hasToolBar = hasToolBar;
    }

    public void initToolBar() {
        if (hasToolBar){
            mToolbar = (Toolbar) findViewById(R.id.toolbar);
            setSupportActionBar(mToolbar);
        }
    }

    public Toolbar getToolBar(){
        return mToolbar;
    }

    public void setHasTabLayout(boolean hasTabLayout){
        this.hasTabLayout= hasTabLayout;
    }

    public void initTabLayout(){
        if (hasTabLayout){
            mTabLayout = (TabLayout)findViewById(R.id.tabLayout);
        }
    }

    public void showProgressDialog() {
        mProgressDialog = ProgressDialog.show(this, "Loading", "Please wait...", true, false);
    }

    public void hideProgressDialog() {
        if (mProgressDialog != null && mProgressDialog.isShowing()) {
            mProgressDialog.dismiss();
        }
    }

    public void showToast(String message) {
        Toast.makeText(this, message, Toast.LENGTH_SHORT).show();
    }

    public void logInformation(Class tag, String description) {
        Log.i(tag.getName(), description);
    }

    public void logError(Class tag, String description) {
        Log.e(tag.getName(), description);
    }

    public void logDebug(Class tag, String description) {
        Log.d(tag.getName(), description);
    }

    public void launchActivity(Class activity, Bundle bundle) {
        Intent intent = new Intent(this, activity);
        if (bundle != null) {
            intent.putExtras(bundle);
        }
        startActivity(intent);
    }

    public void launchActivity(Class activity) {
        launchActivity(activity, null);
    }

    public void loadFragment(){}

    public String getStringResource(int key){
        return getResources().getString(key);
    }
}

现在,我的第一个活动SplashActivity将扩展BaseAppCompatActivity并将其编码如下:
飞溅活动:
public class SplashActivity extends BaseAppCompatActivity {

    private Context mContext = this;

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

//        new Handler().postDelayed(new Runnable() {
//            @Override
//            public void run() {
//                startActivity(new Intent(mContext, IntroductionActivity.class));
//            }
//        }, 4000);
    }

    @Override
    public int getLayoutResource() {
        return R.layout.activity_splash;
    }

    @Override
    protected void initiateViews() {
        setHasToolBar(false);
    }
}

问题是我得到的是白色屏幕,而不是我的布局。为什么?
请提供正确和详细的理由回答。另外,我怎样才能进一步改善我的电流?
编辑:根据请求添加清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidveteran.android.xxx">

    <uses-permission android:name="android.permission.INTERNET" />

    <application
        android:name=".baseclass.BaseApplication"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".activity.SplashActivity"
            android:label="@string/app_name"
            android:theme="@style/AppTheme.NoActionBar">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".activity.IntroductionActivity"
            android:label="@string/title_activity_introduction"
            android:theme="@style/AppTheme.NoActionBar" />
        <activity
            android:name=".activity.LoginActivity"
            android:label="@string/title_activity_login"
            android:parentActivityName=".activity.IntroductionActivity"
            android:theme="@style/AppTheme.NoActionBar">
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.androidveteran.android.restclient.activity.IntroductionActivity" />
        </activity>

        <meta-data
            android:name="AA_DB_NAME"
            android:value="xxx.db" />
        <meta-data
            android:name="AA_DB_VERSION"
            android:value="1" />
        <meta-data
            android:name="AA_MODELS"
            android:value="com.androidveteran.android.xxx.database.model.User" />

        <activity
            android:name=".activity.HomeActivity"
            android:label="@string/title_activity_home"
            android:theme="@style/AppTheme.NoActionBar" />
    </application>

</manifest>

活动\u splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true"
    tools:context=".activity.SplashActivity">

    <include layout="@layout/content_splash" />

</android.support.design.widget.CoordinatorLayout>

content_splash.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:animateLayoutChanges="true"
    android:background="@color/colorPrimary"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context=".activity.SplashActivity"
    tools:showIn="@layout/activity_splash">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical">

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:adjustViewBounds="true"
            android:src="@drawable/logo" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="@dimen/margin_32"
            android:text=""
            android:textColor="@android:color/white"
            android:textSize="36sp"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>

最佳答案

问题是在您的SplashActivity中,您正在调用onCreate()方法

@Override
public void onCreate(Bundle savedInstanceState) {

但是在BaseAppCompatActivity中,您将onCreate()方法与其他参数一起使用
@Override
public void onCreate(Bundle savedInstanceState, PersistableBundle persistentState) {

尝试使用相同的参数。

10-07 12:45