I have a Fragment which contains a TabLayout with a ViewPager. These tabs are 3 different Fragments. The problem is that when I am in the first tab for example and I press the TAB button on an external keyboard or using Vysor app, the focus moves through the different tabs but the user still sees the first tab. Is it possible to keep the focus on the tab that the user is viewing or change tabs as the focus moves?
Related
I have 3 fragments with WebView.
I'm using those three with ViewPager and Tablayout.
The Problem is whenever I'm swiping from 1st page to 3rd page and then going back to first page it's reloading and vice versa.
How do I preserve the state of Webview in Tablayout which has three or four pages.
By default, ViewPager destroys previous Fragments. You can change it using the following line -
mViewPager.setOffscreenPageLimit(CUSTOM_NUMBER);
I've recently implemented the TabLayout within my AppBarLayout & CoordinatorLayout. It works fine except for one issue: the indicator doesn't slide to non-adjacent tabs. That is, when I tap on a tab that is not immediately adjacent to the currently selected tab it will hide and reappear under the newly selected tab. Is there something wrong I might be doing?
When looking at other Google Apps (i.e. Youtube) this is not the behavior I see. Instead I see the indicator smoothly slide over to the tab (even if it's not adjacent to the previously selected one).
Is there a way I can mimic the Youtube tab behavior?
Thanks
EDIT:
I've created gifs of youtube tabs and my tabs. Notice how Youtubes tab indicator never disappears.
YouTube Tabs:
My Tabs:
I have a fragment, which consists of a viewPager in the top of the screen and two buttons at the bottom.
The buttons are for an additional navigation besides the swiping through the pages.
The viewPager consists of about 10 pages with some input fields.
However, when I swipe through the pages and rotate my phone to landscape, the viewPager automatically changes the current item and selects the first page again. Another effect is, that all input data to this point are cleared.
This is really annoying because you have to start all over again.
Is it possible to switch between landscape and portrait mode without this issues?
Some background information:
the app consists of one activity, which is filled with different fragments
a navigation drawer is implemented to choose which fragment will be shown
When you change orientation you are essentially refreshing your activity losing your data such as current page, fragment etc, you need to save your data across the states, i would suggest looking into savedInstanceState.
I have a three tab layout which contains three forms.
I want to switch between tabs and when I move to tab two from tab one after filling the form, and when I navigate back to tab one, I want to display the previously filled content.
How can I achieve this?
Any suggestions.
Thank you.
I have implemented android appcompat actionbar with swipeable tab views using viewpager. I have set two tabs (two fragments). On first fragment (First tab) , I have a button click listener. In this button click listener I need to show the second tab. Though I can swipe between the tabs, I want to call second tab on button click in first tab. How to achieve this?
Well, I found the solution.
On button click listener in first tab,
I set actionBar.setSelectedNavigationItem(1);
This takes me to the second tab :)