Swipe tabs inside one specific fragment - android

Inside my app I am using navigation drawer for my navigation. For each "page" I am using fragments (like showed here: http://developer.android.com/training/implementing-navigation/nav-drawer.html). It works completely fine, but now I want to create swipe tabs. I want to display those tabs only on one of the fragments. Problem is, that tabs are displayed on all fragments, which is ofcourse perfectly normal because tabs are inside action bar. What should I do, to display tabs only on one fragment?

From what I have understood, you are interested in showing action bar only in a particular fragment (not visible when swiping in subsequent fragments). The best way would be to code the action bar in fragment instead of using the action bar in main fragment and then creating swipe views (or sub fragments).
Hope it helps.

Related

problem with viewpager2 and bottomnav working together in android studio

so I'm trying to make small application type of thing where it has bottom navigation bar and viewpager2 working in it. But I want it so that in the first fragment page that application loads in, only there viewpager2 is available to work and be able to swipe, when I switch to next fragment with navigation bar that viewpager2 should basically disappear and not work, therefore my logic was to put that viewpager2 in that single fragment and navigation bar outside in main activity for it to be able to be seen in every fragment. But there is a problem, it almost works, I switch to another fragment with bar view pager disappears but when I go back to that first fragment view pager is just gone, disappeared and I have no idea what's the problem. if necessary I can show what I have written. Thanks in advance

swipe tabs by sliding in one fragment not using other fragments

I have a Fragment with TabLayout, and selecting by current tab it shows the selected month info, not hiding tabs bar and don't using for that many fragments, just updating the view. And now i need swipe tabs by finger sliding. I've searched and watch many examples which using ViewPager and many Fragments to describe each tab.
So how can i do this using only one fragment not other fragments?

Keep fragment's state when changing tabs in bottom bar

Currently I have a ViewPager with 4 Tabs, each one is a different Fragment. I'm now switching my app to Bottom Bar Navigation but there's a problem with keeping the Fragment state and re-using it later.
The Problem :
Initially Tab_1 is visible. If user selects Tab_2 and then re-selects Tab_1, then I can see that the Fragment for Tab_1 goes through onCreate() and re-downloads the data from the server. With ViewPager I was using the setOffScreenPagesLimit() is there something equivalent with bottom bar ?

android listfragment + swiping through items

I'm developing an app, which consist of:
1. main activity, which has action bar, list fragment and some buttons at bottom
2. when you click on some item, another activity is launched - some buttons at top and webview under it.
I have everything working, but now I have to implement swiping between items from list, and I cant figure out how to swipe between activities. I though of changing items into fragments but then I have no idea, how layout should be worked out. I've read blog about viewpager, but as I understood, you can swipe only between 5 tabs with it, and I have 20+ items in listfragment. any ideas? thanks
create one Activity with ViewPager as it's main control. change items into fragments and add them to the ViewPager via FragmentAdapter
You can go ahead and user viewpager. there is no arbitrary limit to the number of pages.
It would be the quickest solution for you and seems to cover what you are doing.

Right way to switch between tabs and change layout of the application?

I'm currently developing an application that has a tab bar, and 3
different views: the first is a master-detail, the second one a
gallery, the third is a simple webview.
I was using the TabActivity, but since Android 3.0, this class is
deprecated and Android reference
suggests to use Fragments.
I switched then to an ActionBar, with Tabs and Action
Items. Inseide the first tab item I have a layout with 2 fragments (my
master-detail view). When I switch through tabs I want that my layout
change as I described above, so I thought to hide the left fragment
(the master listview) and work only in the detail fragment.. but with
this solution I have only one main activity with a lot of fragments
attached to it, and for each fragment displayed I need to modify the
Action Item shown and handle different actions in
OnOptionItemSelected.
Is this a good way to implement this kind of
application or should I consider different solutions?
You should have a single fragment container where the fragments are replaced depending on the tab selected.
One activity and multiple fragments is the right approach.

Categories

Resources