Android: Can i add Tabs within actionBar? - android

I have done practice adding menu on action bar. But for this case I have to add tab in actionbar (not below the actionbar) like below figure:
Please help me to find out the solution. Thanks in advance and sorry for bad English.

For your purpose you can try a simple stuff by creating custom ActionBar like this
You can create custom Action bar like this ..
// gets actionBar reference ..
actionBar = getSupportActionBar();
// This sets custom layout to action bar
actionBar.setCustomView(R.layout.action_provider);
// this is how... .... you get id of layout defined
iv_d = (ImageView) actionBar.getCustomView().findViewById(R.id.action_menu);
Now if you need to show stuff like ActionBar tabs then simply provide background on every layout where each layout contains a text and Image... This will provide a look n feel of ActionBar Tab over ActionBar.
Hope it clears your doubt. Let me know if still you have any concern in same.
Thanks.

Related

ActionBar exactly like Facebook app

I want to build a single-line action bar exactly like in fb, with tabs embedded inside the actionbar in form of icons at center so that when user swipes page the next icon is highlighted.
I'm using HoloEverywhere lib which uses actionbarsherlock internally. I'm aware of actionbar customviews but couldnt figure out how to embed tabs inside the customview.
Please help . If possible please share code sample
Thanks in advance
Just create an xml layout that looks like the Facebook action bar, then do something like this:
ActionBar action = getSupportActionBar();
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.your_header_xml, null);
action.setCustomView(view);
You just have to make the xml, then it should display fine.

How to set drawables on actionbar of my android application

I'm developing an application in which I have to put drawables on top of the actionbar and have to update then from time to time. Here is a layout what I want it to look like.
I want to put a drawable as shown in the picture atttached(The green color drawable not the notification thing). Is that possible to achieve this kind of screen in android? If, so please guide me how to achieve this.
Any kind of help will be appreciated.
This is easy using a custom view. Let me explain you the steps briefly:
Create your custom view in the layout folder. For example, an ImageButton.
Set this view as the custom view of the action bar in your activity. You can do this by calling
getSupportActionBar().setCustomView(R.layout.your_custom_view);
(or getActionBar() instead of getSupportActionBar())
Call setDisplayOptions() with the ActionBar.DISPLAY_SHOW_HOME and ActionBar.DISPLAY_SHOW_CUSTOM options.
If you have other standard buttons in the action bar, inflate the menu.
You can finally set the OnClickListener for your custom view.
This worked for me, hope it helps you!
Create custom view
Use it as ActionView in ActionBar
In onCreateOptionsMenu get a reference to your view and update it when needed

Hide App name and it's bar

I've been trying to remove this bar (cant hotlink images, yet, check next link):
http://i.imgur.com/fRvMW.png
But I can't achieve it.
Tried the following:
Added into manifest the following:
android:theme="#android:style/Theme.NoActionBar"
But resulted as crash. Probably because I don't have this "Theme". I can't find out what should I write here.
Also tried to remove manually on each Fragment by Graphical Layout, selecting "No action bar", and it doesn't show up on the "preview" but it's shown in the app, probably because its the wrong place to configure it.
Note that it's with fragments. I searched about doing it by code, but I just found options to do it for activities.
So, my question is: How can I hide the App Action bar?
Edit:
SOLVED
On my code, I've this:
final ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
So, just added:
bar.hide();
And everything is working. Even if the tabs names aren't shown, the navigation still works (Swaping right and left for swapping fragments.)
Have you tried this?
ActionBar actionBar = getActionBar();
actionBar.hide();

Can i show Tabs without Action Bar in android 3.0?

I want to show tab in my fragment but not on Action Bar?
Is this possible, any link or code might help??
Thanks in advance
I got the tabs without the rest of the ActionBar by removing the home button and the title, like this:
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
and not overriding:
onCreateOptionsMenu
That way the ActionBar would be empty and Android won't display it.
You can use the tabWidget. In a part of my application, I have a TabActivity where the inner activity uses fragments. So, it is possible. It may not be the best solution, but I had to do what the customer wanted.
It depends what kind of tabs you want to use. In my app I'm using ViewPager together with indicator and it works great, so maybe it will suite you. I hope I've understood your question.

Customize the action bar color background changing

I am trying to add and action bar to my app, and customize it.
i used onCreateOptionMenu() and Inflaters to add to my code.
but i don't know how to customize background and remove that package name which appears next to the logo so i can give more "Room" to my items to be displayed correctly.
can anybody help please?
Thank you in advance.
I would suggest to create a custom action bar in layout folder and use it with below code:
ActionBar actionBar = getActionBar(); //Applications action bar isntance
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
actionBar.setCustomView(R.layout.my_action_bar);
If you use this, you can directly use action bar view's content and do whatever you want.

Categories

Resources