我想将一个下拉菜单添加到Android操作栏中,就像在Google地图应用中一样。我不想包含任何第三方库,如actionbarsherlock,因为我相信我们可以使用android SDK来完成此操作。如何将下拉菜单添加到Android Action Bar
-1
A
回答
1
您可以使用工具栏从程序兼容性库作为你的动作条,然后在工具栏中添加一个spinner
因为工具栏就像一个普通的布局,你可以在其中添加视图。
这里是一个示例:
<android.support.v7.widget.Toolbar
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="@dimen/triple_height_toolbar"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" >
<Spinner
android:id="@+id/planets_spinner"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
,并找到在工具栏中的微调是调用工具栏内findViewById
。
toolbar = (Toolbar) findViewById(R.id.tool_bar);
Spinnertitle = (Spinner)toolbar.findViewById(R.id.toolbar_title);
Link Here是如何在你的应用程序
[操作栏上的下拉菜单(的+0
将工具栏添加为“ActionBar”需要调用'setSupportActionBar()',您只需将工具栏实例作为参数传递。 – TheLittleNaruto
相关问题
- 1. 如何将下拉菜单添加到此菜单?
- 2. 如何将文本添加到Android的Action Bar Home按钮?
- 3. Animate Android Action Bar菜单项外观
- 4. 将'animate'添加到jquery下拉菜单
- 5. 将hoverIntent添加到jquery下拉菜单
- 6. 将下拉菜单添加到magento
- 7. 将下拉菜单添加到jqGrid
- 8. 将hoverintent添加到ajax下拉菜单
- 9. FragmentActivity Action Bar选项菜单
- 10. 如何将下拉菜单添加到JTable单元
- 11. javascript函数添加到下拉菜单
- 12. 如何添加一个下拉菜单到我的菜单栏
- 13. 如何将下拉菜单项添加到我的水平菜单栏?
- 14. 将CSS滑出动画添加到Reponsive下拉菜单中
- 15. 如何添加下拉菜单?
- 16. 如何添加子下拉菜单
- 17. 如何将glyphicon添加到引导程序下拉菜单
- 18. 我将如何添加第二列到此下拉菜单?
- 19. 如何将选项添加到下拉菜单中?
- 20. Android Action Bar
- 21. 添加延迟到jquery下拉菜单
- 22. 使用特定模板时将下拉菜单添加到引导菜单
- 23. Action Bar菜单项复制运行
- 24. 带滑动菜单的Sherlock Action Bar
- 25. 如何将图标添加到android上下文菜单?
- 26. aspx下拉菜单添加项目如何获取下拉菜单实例
- 27. 显示Android Action Bar
- 28. 如何将填充添加到垂直下拉菜单而不需要弄错下拉菜单?
- 29. 将值添加到带有表单的下拉菜单
- 30. 将jQuery添加到表单以显示/隐藏下拉菜单
可能重复http://stackoverflow.com/questions/11376101/drop-down-menu-添加一个工具栏on-action-bar) –
为什么用上面链接列出的相同图像创建相同的问题? –
你很有信心!为什么你还在尝试什么呢? – TheLittleNaruto