I am using ActionBarSherlock and ViewPagerIndicator to create an activity that has both tabs and list navigation.
The tabs are backed by a FragmentStatePagerAdapter and allow the user to navigate between the different sections of the app. The list navigation allows the user to toggle the view mode of the tab they are currently on e.g. if they are viewing search results they are able to toggle between list and grid mode.
The problem that I am having is that when i scroll between the tabs the list navigation intermittently stops working. I can click on the spinner and it displays the list of options but when i select one of them the text in the spinner:
Doesn't get updated,
onNavigationItemSelected() doesn't get called.
(For some reason using a FragmentPagerAdapter rather than a FragmentStatePagerAdapter seems to stop the issue occurring as frequently but it still happens occasionally.)
Any ideas?
Thanks
I think should not use the tab navigation built in the ActionBar.
You can use the PagerTitle interface that is available in ViewPager. http://developer.android.com/reference/android/support/v4/view/PagerTitleStrip.html
Or you can use the below great libraries
http://viewpagerindicator.com
https://github.com/astuetz/PagerSlidingTabStrip
Related
I have an Activity with 4 action bar tabs, each one is a different fragment. I have my own TabListener class which implements ActionBar.TabListener to manage the fragments as they change.
However what I want is for a user to click a different tab and the tab indicator to slide over to the new tab in a smooth animation. I tried setting a custom animation for my fragment transactions but that doesn't affect the tab indicator.
Is this possible? And if so could someone point me in the right direction?
I have looked through a lot of posts but I'm still unclear as to whether this is possible using the standard android SDK (no third party libraries like ActionBarSherlock) and ActionBar tabs. Plus searching for it yields mainly results for sliding between tabs or animating fragment transactions, nothing relating to the indicator.
Any help whatsoever would be appreciated.
I'm trying to implement an application with a specific view. It needs to have a horizontal bar at the top that contains the app icon, and other buttons and spinners. These items must be static and should appear on every page of the app.
Below that horizontal bar will be a Tabbed component, with the tabs being horizontal at the bottom of the page. I can also implement the desired behavior with the tabs on top of the Tabbed component. Each tab will obviously change the fragment being displayed within the tab's frame.
I am working on an implementation that uses the ActionBar and the menu options. However, I can't get the menu options (my buttons and spinners) to appear above the tabs. And I'm not sure if menu options is the right approach. Any ideas?
Silly me! the answer was right there. I simply had to turn the title bar back on (only with no title) and the menu options would appear right into that title bar.
keep in mind that this feature is heavily dependent on the version of android and model of device that you have.
Older phones have a menu button which will bring up the same menu, as do some modern phones (like the galaxy SIII), so, be sure to test this everywhere so you know what the end-user will actually experience.
I want to create a app with a menu at the bottom of the screen. This menu should be visible any time the app is started.
Im working with fragments, so the menu is one fragment.
So I have only one Activity as controller which loads different fragments above the menu fragment.
Because I want to create clean code, i dont know how to solve the problem that the Activity class is too big.
In other words, i want to create different controller within the same activity. How to do that?
Is there another approach to solve this issue?
You should be using the split action bar This allows you to put the Actions and overflow menu on the bottom of the screen. I believe you can use Action Bar Sherlock for backwards compatibility to older versions of Android. See their site for detail.
Another possibility is to look into using fragments with the ViewPager . Here is a library that works with compatability as well ViewPageIndicator . Here is a blog post , like I indicated in my comment I got this working with the tabs showing at the bottom and the pages above.
How can I allow horizontal tab navigation (swipe views) if I'm using action bar navigation tabs?
Is there anything special I have to do to get this to work with ActionBarSherlock?
The code-generated stuff for a "Tabs+Swipe" activity (from BlankActivity in the new activity wizard in Eclipse) has code for this. Basically, your tabs tie into a ViewPager, calling setCurrentItem() to change the page, rather than running their own FragmentTransaction or otherwise affecting the UI. The ViewPager handles the horizontal swiping, and you populate those pages using some form of PagerAdapter (one is code generated for you). See this very related question and answer for more.
Is there anything special I have to do to get this to work with ActionBarSherlock?
Other than standard stuff for using ActionBarSherlock, nothing out of the ordinary should be required. ViewPager is in the Android Support package, which ActionBarSherlock also needs, so you will have that already in your project.
Note, though, that action bar tabs only sometimes show up as tabs. In some screen sizes and orientations, they are automatically converted into a drop-down list (per "list navigation" with the action bar instead of "tab navigation"). If you want to use tabs all of the time, rather than using action bar tabs with ViewPager, use PagerTabStrip (from the Android Support package) or a suitable indicator from ViewPagerIndicator instead.
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 !