【问题标题】:ActionBar Layout overlapping while using Fragments使用片段时操作栏布局重叠
【发布时间】:2013-08-30 08:44:56
【问题描述】:

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

 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

【问题讨论】:

    标签: android layout android-actionbar fragment


    【解决方案1】:

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

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

    【讨论】:

    • 那个: ???????
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多