是否可以使用下拉菜单和选项卡导航操作栏中的? [英] Is it possible to use dropdown AND tabs as navigation in the action bar?

查看:174
本文介绍了是否可以使用下拉菜单和选项卡导航操作栏中的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以兼得,一个微调/下拉菜单在操作栏的顶部,标签的正下方?我想用微调的操作栏的视图开关控制器(即表视图或图表视图)的顶部,而下面的选项卡会显示不同的数据表。

Is it possible to have both, an spinner/dropdown at the top and tabs just below in the action bar? I want to use the spinner at the top of the action bar as view-switch controller (i.e. table view or chart view) while the tabs below is going to show different lists of data.

下面的屏幕截图显示了正是我想要实现:

The following screen shot illustrates exactly what I want to achieve:

如果这是不可能有这两种模式在操作吧,我可以把一个TabWidget在我的内容视图顶部。不过,我有点不确定我是否应该有一个片段或每片一个活动。

If it's not possible having both modes in the action bar, I could put an TabWidget at the top of my content view. However, I'm little bit unsure if I should have one fragment or one activity per tab.

推荐答案

编辑:

是否可以使用下拉菜单和选项卡导航操作栏中的?

Is it possible to use dropdown AND tabs as navigation in the action bar?

没有。在code在<一个href="https://github.com/android/platform_frameworks_base/blob/master/core/java/com/android/internal/widget/ActionBarView.java"相对=nofollow> ActionBarView 的(其中setNavigationMode(int)的呼叫结束)使用switch语句,所以这些模式不能结合

No. The code in ActionBarView (where the setNavigationMode(int) call ends up) uses a switch statement, so the modes can't be combined.

操作栏导航模式和我的previous答案的组合仍​​然是一个有效的选项,但: 你可以在你的操作使用自定义视图酒吧和使用 ViewPager 的内容。在ViewPager每个选项卡将是您可以手动更新一个片段父活动(更改视图类型)时微调改变。

Some combination of the action bar navigation modes and my previous answer is still a valid option though: You could use a custom view in your Action Bar and use a ViewPager for the content. Each tab in the ViewPager would be a fragment that you can update manually (change the view type) from the parent activity when the spinner is changed.

旁注,也有第三方库,如 ViewPagerExtensions ,让固定选项卡的外观,而无需使用动作条的标签。

Side note, there are 3rd party libraries such as ViewPagerExtensions that give the fixed tabs appearance without having to use the ActionBar tabs.

这篇关于是否可以使用下拉菜单和选项卡导航操作栏中的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆