1

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

 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.
    }

}

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

4

1 回答 1

0

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

 android:configChanges="orientation|screenSize|keyboardHidden"
 android:windowSoftInputMode="adjustPan"
于 2013-08-30T09:00:26.660 回答