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()
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
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
I have one activity which has two fragments.
I have defined following option for the activity in manifest file-
android:uiOptions="splitActionBarWhenNarrow"
I want the action bar at bottom for one fragment and at top for another fragment.
How can I do this?
The action bar is tied to the activity, not the fragments. If you need a bar with buttons somewhere in the middle of your activity, you'll have to add something yourself. Perhaps a button bar that is styled to look like an action bar.
I am using sherlock action bar API for action bar implementation,My problem is
I am using fragmentation in android.my main activity class is using more then 3
fragments to display things now I need to access that action bar in every fragment
but whenever I moved from main activity to any other fragments action bar is not
accessible there. when ever I call any action it gives my null pointer exception kindly need your help.
Be sure that other fragments are extending SherlockFragment
And then call this method:
this.getSherlockActivity().getSupportActionBar().setTitle(TheString);
if I understand the question, you need to reach the actionbar from the fragment inside an activity. So once you reach the activity from the fragment, from there you can get the actionbar. say that you need to set the title:
from the fragment (it should be a SherlockFragment) do the following
getSherlockActivity().getSupportActionBar().setTitle(theTitle);
Can we use activities in action bar class, using one activity for each tab rather than fragments? If yes then how its possible?