解决FragmentTabHost切换标题栏变更问题
来源:互联网 发布:谢霆锋厨艺知乎 编辑:程序博客网 时间:2024/05/21 15:01
现在都流行FragmentTabHost布局.但是所有的fragment都是共享一个actionbar,但是我们又想给每个fragment定义自定义的标题栏.百度google了好久也没有找到解决方案.最后想到了一个笨办法.解决方法如下.如果你们有更好的方案,请留言.
第一个fragment中我定义了自定义布局的actionbar
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {initActionBar();layoutView = inflater.inflate(R.layout.fragment1, null);return layoutView;}private void initActionBar() {ActionBar actionBar=getActivity().getActionBar();actionBar.setTitle("第一个页面");//查找布局文件 并且为按钮添加点击事件View view=View.inflate(mActivity, R.layout.action_title, null); actionBar.setDisplayShowCustomEnabled(true);//可设置自定义布局 actionBar.setCustomView(view);}
第二个fragment把自定义布局设置为空,或者你也可以重新设置一个自定义布局的actionbar,这样就可以实现每个fragment都有不同的actionbar.
@Overridepublic View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {initActionBar();layoutView = inflater.inflate(R.layout.fragment2, null);return layoutView;}private void initActionBar() {ActionBar actionBar=getActivity().getActionBar();actionBar.setTitle("第二个页面");actionBar.setCustomView(null);}
0 0
- 解决FragmentTabHost切换标题栏变更问题
- FragmentTabhost解决IllegalStateException问题
- 解决android FragmentTabHost + viewpager + fragment 嵌套布局切换出现白屏什么都没有问题
- 解决定时器时间变更问题
- android fragment+ FragmentTabHost+viewpager 切换状态不保存的问题
- 【问题解决】FragmentTabHost 底部菜单栏,切换Frgment时重新加载问题
- 关于fragmentTabhost点击底部切换不了的问题
- FragmentTabHost 阻止切换
- FragmentTabHost底部切换
- 解决FragmentTabHost + WebView 输入框无法输入英文数字问题
- FragmentTabHost的应用,完美解决滑动的时候,一些问题
- FragmentTabHost、Viewpager、Fragment使用过程中白屏问题及解决
- FragmentTabHost切换Fragment,与ViewPager切换Fragment时重新onCreateView的问题
- 【Android】自定义标题栏 (解决了标题栏两侧空隙问题)
- 解决android自定义标题栏充满的问题
- 解决android自定义标题栏充满的问题
- 解决android自定义标题栏充满的问题
- 解决android自定义标题栏充满的问题
- Android的MVC模式:
- hdu1560
- java 枚举类型enum 的使用
- window.print打印指定div-打印网页指定区域
- 怎样定义一个数组,又忘了……
- 解决FragmentTabHost切换标题栏变更问题
- Bat脚本处理ftp超强案例解说
- 【HDU】2768 Cat vs. Dog 最大独立集
- TestNG入门指南
- 回显分页后选择的多选框
- 计算机基础--网络知识02
- 【儒豹段子精选】同学当心,老师也很逗B的~~~
- 11G R2 rac to 11G R2 rac dataguard Switchover
- COCO2dx-学习笔记