使用片段时ActionBar布局重叠

时间:2013-08-30 08:44:57

标签: android layout android-actionbar fragment

我刚刚在我的应用程序中发现我使用带有片段的操作栏,当我将应用程序留在后台一段时间后重新打开。 混合的各种布局发生了混乱...可能是由于我如何配置选项卡的类。 我在这里写下来源:

 private class TabListener<T extends Fragment> implements ActionBar.TabListener {

    private Fragment mFragment;

    private final Activity mActivity;

    private final String mTag;

    private final Class<T> mClass;

    public TabListener(Activity activity, String tag, Class<T> clz) {

        mActivity = activity;

        mTag = tag;

        mClass = clz;

    }
    public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {

        // Check if the fragment is already initialized

        if (mFragment == null) {

            // If not, instantiate and add it to the activity

            mFragment = Fragment.instantiate(mActivity, mClass.getName());

            ft.add(android.R.id.content, mFragment, mTag);


        } else {

            // If it exists, simply attach it in order to show it
            ft.show(mFragment);
            //ft.attach(mFragment);

        }

    }
    public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {

        if (mFragment != null) {

            // Detach the fragment, because another one is being attached

           // ft.detach(mFragment);
            ft.hide(mFragment);
        }

    }
    public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {

     //ft.replace(tab.getPosition(),mFragment);

        // User selected the already selected tab. Usually do nothing.
    }

}

当我将应用程序留在后台一段时间时会发生这种情况'并且在此期间我使用其他...我只是无法弄清楚它取决于什么... ram?我在代码中做错了吗? 以下是截图:
 http://img593.imageshack.us/img593/2406/dmc4.png

1 个答案:

答案 0 :(得分:0)

在清单中的活动标记中提及以下内容:

 android:configChanges="orientation|screenSize|keyboardHidden"
 android:windowSoftInputMode="adjustPan"