防止在Android中重新加载活动

时间:2018-02-20 23:02:16

标签: android android-activity refresh reload android-fragmentactivity

我的问题几乎与

相同

Similar Problem

但解决方案对我不起作用。

在我的两个不同的应用程序中,我使用相同的菜单类文件,但它们显示不同的结果。我已设置菜单,其中单击其中一个项目指向“AboutActivity”。当我在一个应用程序中从菜单的“AboutActivity”返回时,它会刷新“MainActivity”,但在另一个应用程序中则不会。两个应用程序之间的区别是,第一个有两个活动(主要+关于),第二个有五个活动(主要+关于+主要2 +主要3 + ..)

我在Manifest中使用的代码。

     <activity android:name="school.infinity.maruf.agecalculator.about"
        android:label="About"
        android:parentActivityName="school.infinity.maruf.agecalculator.MainActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|layoutDirection|touchscreen"/>

这是类文件中使用的代码

    public boolean onOptionsItemSelected(MenuItem item) {
    // User clicked on a menu option in the app bar overflow menu
    switch (item.getItemId()) {

        case R.id.about:

            Intent intent=new Intent(this,about.class);
            startActivity(intent);
       return true;
}

我在清单

中使用了以下代码来进行MainActivity
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize|layoutDirection|touchscreen"/>

现在如何在从“AboutLayout”回来的过程中停止重新加载/刷新主要活动?

0 个答案:

没有答案