When I click one of tabs, I just want to show a dialogue on top of current view without switching the tab.
I could achieve this behavior by overriding onTabChanged when I used TabHost and TabSpec.
But now I switched to using actionbar's tab, and having hard time finding the solution.
Related
I have an activity that have attached to ActionBar a few Tab (4 by now).
I would like to hide the Tab line as the keyboard shows, and then show the Tab again as the keyboard is closed.
I've searched several answers in here, but no one seems to do what I want (everyone use external libraries for hiding the Tabs on listView scroll, or "delete" dynamically the tab and then recreate them).
How can I achieve that?
I've set up a ViewPager in my App with tabs, but I need to position the tabs underneath a button so the layout would be
TitleBar
Button to search activities on a day
Tabs of each day there are activities
Is that kind of layout possible to do using Tabs or will I need a different approach to solve this?
The way the activity is running is theres a main activity, and the layout is just the button and a FrameLayout, and the the list (where the ViewPager is) is set up in a fragment and the fragment is loaded into the FrameLayout. I don't know if this is the best method for this so if not please add your recommendations of a better method I could use.
EDIT: If I could get it so all the tabs were at the bottom of the screen this would also be fine.
Is that kind of layout possible to do using Tabs
Not with action bar tabs. Not only can you not control where the tabs go, you cannot even control if there will be tabs versus a drop-down list.
will I need a different approach to solve this?
You are welcome to use some other tab solution (ViewPager with a tabbed indicator, FragmentTabHost, etc.) where you have more control.
Note that your proposed design does not adhere to Android design aesthetics. Most apps would not have "Button to search activities on a day", but instead a search action bar item, or perhaps a SearchView in the action bar.
If I could get it so all the tabs were at the bottom of the screen this would also be fine.
This is completely against the Android design guidelines. Don't use bottom tab bars on Android.
I set up an actionbar in my application. I get back the ActionBar by calling the Activity.getActionBar(). Then I set all the Tabs I need thanks to ActionBar.addTab() and ActionBar.newTab() methods.
When I am in landscape mode, all my categories are displayed on screen (i.e., user can see all available Tab). I select the last category (on the right of the screen).
After a screen rotation (I'm now in Portrait mode), I save the selected category and restore it on my ActionBar thanks to ActionBar.setSelectedNavigationItem() method.
Although the Tab is well selected in the ActionBar (i.e., its label is underlined/highlighted), the considered Tab is not currently visible on screen. Indeed, the screen width is to small to display all available Tabs of ActionBar.
My problem is, setSelectedNavigationItem doesn't make the ActionBar scroll to the selected Tab so that the user can see its label. The user must manually scroll into ActionBar to visualize which Tab is currently selected.
Could someone help me solve this problem ?
As #Vadi said in comment: tab.select(); will automatically scroll to the selected tab. My guess is that you pass the savedinstancestate to super and also set the selected. This would most likely cause the glitch.
well, I have my Android app that have 4 main options. For that I created a TabActivity with this options.
Problem, when I enter to one of this, a activity is called. Cool. Imagine I have a list and when I click on one row I open other activity, the tab will disappear what is correct. But I want this tabBar always.
how can I achieve this?
if I copy/page this tab in every activity I need it it will load the ones that are attached to the tab and wont show the one that I opened before, right?
You should try with FragmentActivity. There is a addTab function to add tabs to action bar, in which you set tabs. With fragments and action bar what you want to do is possible
Take a look at Action Bar Sherlock that includes actionbar compatibiliy with tabs and more for non Honeycomb versions of Android.
I'm building an application that requires Tabs, which are now deprecated. The dev guide says to use Fragments to replace the tabs instead. However, my application needs to have fragments within each tab, which means fragments inside fragments, which isn't allowed. Does anyone know of a possible work around for this?
While the action bar support for tabs is designed to make it easy for the contents of a tab to be a fragment, that is not strictly required. You could use ViewFlipper, repeated calls to setContentView(), or something to arrange to change other stuff when the action bar tab is selected.
Prior to the native action bar (Android 1.x/2.x), either stick with classic tabs, or use something like Action Bar Sherlock to get an action bar and tabs.
I fake tabs by having a "tabs" fragment across the top that contains multiple toggle buttons. Below that I have a merge view containing a separate fragment for each tab.
I respond to taps on a toggle button by toggling the other buttons "off", showing the fragment for that "tab", and hiding the others.
its little late , but yes you can :) here's an example
but for fragment inside fragment inside tab isn't an android native way, you have to start a new fragmentActivity if you want to show detail of fragment. you can but is not an android way !