I have a Activity and it has include more than one fragment.
I know it can use requestWindowFeature(Window.FEATURE_NO_TITLE); to hide the title in Activity.
But I don't want to hide title for all fragment.
Can I hide the title for preference fragment ?
Based on what you say, you will have to use more than one activity. For the fragments that are in a same activity, the title bar is either shown or hidden.
Do not use requestWindowFeature(Window.FEATURE_NO_TITLE); We can get actionBar and hide it after setContentView
When active fragment, show action bar
When fragment detach , notify activity and activity can hide the action bar
Above is my current implement and seems work. Still testing :-D
Simple sample here - https://bitbucket.org/jimmy64/fragmentsample
Related
I have an android activity extended from ActionBarActivity.
My Activity content ruled by state pattern. When state changes, screen also changes somehow. I need ActionBar just in one of 3 states I have. How can I hide ActionBar by default and show it only in one State of my Activity?.
Thanks in advance!
For hiding use
getSupportActionBar().hide();
and for Showing it again use
getSupportActionBar().show();
look at this example its work for me by default i hide my action bar layout after that i am showing it on user data requirements
How to hide and show action bar
When I add a fragment to my xml file, it shows all the content but not the fragment's action bar. How can I change the default behaviour to show the actionbar too?
From the Fragment, in your onCreate() method, you can try calling
getActivity().getActionBar().show();
you can set the title by using
getActivity().getActionBar().setTitle("title");
I have an activity with three fragments. Fragment A has 1 item in actionbar. Fragment B has 4 items in actionbar, and Fragment C has 1. So, I want to have split actionbar when I change to fragment B, but I don't want split action bar in A-C fragments, because there is no reason to fill de bottom of the screen with a bar only for one item.
Can I change actionbar mode when I change between fragments?
Not sure if this can be done using Fragments as ActionBar is associated with the Activity. However, I tried what you are looking for with two activities and it worked.
Add the action bar in onCreateOptionsMenu in both the activities and then add
getWindow().setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);
right before onCreate method of the activity in which you want the split action bar to appear. Thats it. Simple isn't it. :)
You can also hide and show it using getActionBar.hide() and getActionBar.show() methods respectively.
(The only thing I missed is checking this with support libraries. Will try and update you on that as well)
Let me know if this helps you in some way. Happy coding :)
I have an action bar set up in the main activity, and this creates a bunch of fragments. However, there are several fragments that require the action bar to be hidden, but I can't refer to the ActionBarSherlock class inside a fragment.
How can I hide the action bar?
Thanks for any suggestions.
Actually you can refer to ActionBar via activity which you can get from a SherlockFragment by calling SherlockFragment.getSherlockActivity(), then just call SherlockFragmentActivity.getSupportActionBar() and then hide()
I am trying to create an app that when you click through each page of the app the title bar doesn't move. I can create an xml with the same title bar but every time you go on to a new page the title bar disappears for a second and then reappears with the new page.
Does anybody have any suggestions/code that can help me with this?
Many Thanks
Take a look to Fragments. If you implement "each page of the app" as a separate Fragment - instead of Activity - then you can embed and switch these Fragments into the layout of the main Activity, obtaining what you need.
Use a tabActivity and have the activities inside it.
hide the tab bar as given here tab bar hiding issue android
Use mTabHost.setCurrentTabByTag to set the tab