I want to use an activity in two manners
As the main logic of the Activity is to display the list of items I would like to handle these two cases in the same Activity. Nevertheless in the 1. I want to show the actionbar so that the user can navigate from there to wherever wanted. In the 2. case I dont want any actionbar to be shown, all the user can do is choose an item or press cancel/back.
What is the best way to achieve this. My first guess would be two themes which I set dynamically what of the two cases is required. But I wonder if there is also a way to easily remove the actionbar from the screen programmatically which would save me from declaring two themes etc. Any suggestion how you handle this requirement would be very helpful.
Thanks
How about this?
public void hideActionBar(){
getActionBar().hide();
}
Source: http://developer.android.com/guide/topics/ui/actionbar.html
Use this:
getActionBar().hide();
Android documentation for action bar hide method
If you want to actually remove the action bar (not create it in the first place) as opposed to create it but then just hiding it right away, you can do it via themes or via code.
Via theme or styled attributes:
Use one of the predefine system themes like Theme.Holo.NoActionBar or its variants. This is the easiest way to do it.
If you want to define using attributes inside your custom theme, then you could do this:
<resources>
<style name="MyTheme" parent="some_parent_theme">
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBar">false</item>
<item name="android:windowFullscreen">true</item>
</style>
</resources>
Now add this theme to your activity or application.
Via code (make sure you call this before setContentView in Activity.onCreate):
requestWindowFeature(Window.FEATURE_NO_TITLE);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With