简体   繁体   English

如何将标签添加到SherlockFragment,而不是SherlockFragmentActivity中

[英]how to add tabs to a SherlockFragment, not in a SherlockFragmentActivity

I am working in a project,that has tabs to the bottom of the page. 我正在一个项目中,该项目位于页面底部。 In one particular tab, I have to replace the existing Fragment with a ShelockFragment . 在一个特定的选项卡中,我必须用ShelockFragment替换现有的Fragment Now the fact is when I am trying to create the actionbar in my sherlockfragment code, I am not getting the getSupportActionBar (), which I get from a SherlockFragmentActivity . 现在的事实是,当我尝试在sherlockfragment代码中创建操作actionbar时,没有得到从SherlockFragmentActivity获得的getSupportActionBar ()。 how can I overcome the situation ? 我该如何克服这种情况? I cant change my SherlockFragment to be a SherlockFragmntActivity . 我无法将SherlockFragment更改为SherlockFragmntActivity Because doing that wont let me replace my existing fragment to be replace by the sherlockFragment . 因为这样做不会让我替换现有的fragment ,而由sherlockFragment替换。

I have only one portion to use sherlock actionbar . 我只有一部分可以使用sherlock actionbar

Please help me !!! 请帮我 !!!

1) Parent layer (All Tabs are here) -EXTENDS SherlockFragmentActivity ; 1)父层(所有选项卡都在这里)-EXTENDS SherlockFragmentActivity; 2) Its child (class[OR tab] where u want to use actionbar, ie CLASS holding actionbar )- EXTENDS SherlockFragment [HERE NEED NOT HOLD ACTIONBAR] ; 2)它的子级(您要在其中使用操作栏的类[OR选项卡],即CLASS持有操作栏)-扩展SherlockFragment [这里不需要保留操作栏]; 3) Your actionbar -EXTENDS SherlockFragment ; 3)您的操作栏-EXTENDS SherlockFragment;

You need not to get getSupportActionBar() in ur (2nd class ie TAB class). 您无需在ur(第二类,即TAB类)中获取getSupportActionBar()。 Just define it in Parent Class(1st pt.) and let it hold ur action bar there. 只需在“父类”(第1点)中定义它,然后让它在其中保持您的操作栏即可。 When required tab is taped just show those actionbars and in other cases HIDE these actionbar. 当需要的选项卡被录音时,仅显示这些操作栏,而在其他情况下,请隐藏这些操作栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM