如何创建我的所有活动的自定义标题栏? [英] How can I create a custom titlebar for all of my activities?
问题描述
我见过创建自定义标题栏的例子很多:的 HTTP://zaman91.word$p$pss.com/2010/03/16/android-how-to-add-custom-title-bar/ </A>
I have seen many examples of creating a custom titlebar: http://zaman91.wordpress.com/2010/03/16/android-how-to-add-custom-title-bar/
是否有这样做的一个简单的方法?我认为这是一个有点矫枉过正不得不实施的onCreate自定义标题栏code()的每个活动。
Is there a simpler way of doing this? I think it is a bit overkill to have to implement the custom titlebar code in onCreate() for every activity.
推荐答案
为什么不使用包括什么呢?把你的标准标题栏的设计到版式的XML文件,然后将其包含在每个活动布局:
Why not use an include? Put the design of your standard titlebar into a layout XML file, and then include it in each activity layout:
<include layout="@layout/my_title_bar" />
然后创建my_title_bar.xml遏制栏的内容。
And then create my_title_bar.xml to contain the contents of the bar.
如果您在标题栏中点击观点,你需要一点点code,但你可以继承活动提供点击的方法。
If you have clickable views in the title bar you'll need a little code, but you could subclass Activity to provide click methods.
这篇关于如何创建我的所有活动的自定义标题栏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!