[英]How to add button to title bar?
I am making an android app. 我正在制作一个Android应用程序。 I need to add a button to the title bar of an activity.
我需要在活动的标题栏中添加一个按钮。 I cannot put it in the action bar because of backward compatibility problems.
由于向后兼容性问题,我无法将其放在操作栏中。 I searched a lot but couldn't find a satisfactory solution for this.
我进行了很多搜索,但找不到令人满意的解决方案。 Thanks.
谢谢。
Action bar requires API level 11 to work, my app's minimum is 9
操作栏需要API级别11才能正常工作,我的应用程序的最低要求为9
Use a backport, like ActionBarSherlock , which offers action bars back to API Level 7. More importantly, it does so using an API compatible with the official action bar implementation, and so dropping ActionBarSherlock in a year or two (when you drop support for API Level 9-10) will be fairly easy. 使用诸如ActionBarSherlock之类的反向端口 ,该端口将动作条提供回到API级别7。更重要的是,它使用与官方动作条实现兼容的API来做到这一点,因此在一两年内放弃ActionBarSherlock(当您放弃对API的支持时) 9-10级)将相当容易。 And, your app will have a consistent look and feel with other Android apps.
并且,您的应用将与其他Android应用具有一致的外观。
I needed something similar and created a custom title bar as follows: 我需要类似的东西,并创建了一个自定义标题栏,如下所示:
requestWindowFeature(Window.FEATURE_NO_TITLE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
隐藏默认栏requestWindowFeature(Window.FEATURE_NO_TITLE);
(if I remember correctly, it is crucial to do this before setting the content view of your activity).
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.