android - Tabbar 和 Preference 页面在 android 中聚集在一起

标签 android tabs preferences

我正在尝试为一个应用程序创建一个设置页面,这个应用程序需要在底部有一个标签栏。我能够使用 <PreferenceScreen/> 创建首选项页面还使用 TabHost 创建了一个选项卡.但我的问题是我无法弄清楚如何将 Tab-bat 带到 PreferenceScreen 页面。 我想带来这样的东西:

enter image description here

提前致谢

快乐编码...

最佳答案

你可以用Tab Fragment测试一下,这里是一个Tab Fragment in ActionBar , then 中的每一个都必须像 FragmentTabs.java 一样处理这样做:

 public void onTabChanged(String tabId) {
            TabInfo newTab = mTabs.get(tabId);
            if (mLastTab != newTab) {
                FragmentTransaction ft = mActivity.getSupportFragmentManager().beginTransaction();
                if (mLastTab != null) {
                    if (mLastTab.fragment != null) {
                        ft.detach(mLastTab.fragment);
                    }
                }
                if (newTab != null) {
                    if (newTab.fragment == null) {
                        newTab.fragment = Fragment.instantiate(mActivity,
                                newTab.clss.getName(), newTab.args);
                        ft.add(mContainerId, newTab.fragment, newTab.tag);
                    } else {
                        ft.attach(newTab.fragment);
                    }
                }

                mLastTab = newTab;
                ft.commit();
                mActivity.getSupportFragmentManager().executePendingTransactions();
            }
        }

然后您需要更改操作栏上选项卡的样式,您可以检查操作栏样式或 styleActionbar直接引用,我相信actionBarTabStyle是您应该开始自定义的地方。

另外不要忘记首选项的 fragment 必须从 PrefrenceFragment 扩展

关于android - Tabbar 和 Preference 页面在 android 中聚集在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8493101/

相关文章:

vim - 比较 Vim 中的两个选项卡

jquery-ui - jQuery UI 选项卡 : how to place div with float:left property into tab?

java - Eclipse 首选项页面

eclipse - 'Ignore potential matches' 的含义

android - 等待我的代码使用 Kotlin 完成从 API 调用获取所有信息

android - 蓝牙 Bluez : Unable to create crypto contex

android - 如何在选项卡上方添加行android tablayout

Cocoa - 关于 NSUserDefaults 值更改的通知?

android - <Include> 一个带有 fab 按钮的 xml 文件

android - 实现自定义可检查的相对布局