Android Automatically Selecting Tab when Scrolling Through Tabview - android

I'm working on an app where data is displayed in specific tabs by date (i.e. 31 different tabs). These are quite a lot of tabs and I want to make it more fluid for the user to scroll through the tabs. So, my goal is to automatically select the center tab, so that you can simply scroll through the tabs without having to click on them again.
My question: Is this possible? I first saw this concept in the trends overview of the "Samsung Health" app. How was that handled there?

Related

How can you have multiple instances of the same fragment in multiple pages of a ViewPager2?

I am creating an app in Kotlin. The desired operation is that when the user opens the app, the user will be presented with a menu offering navigation options. Upon tapping one of the icons, the user will then be presented with another menu. From that menu, several things can happen. This works fine in my app. The problem comes when I add ViewPager2. I would like the user to have multiple "pages" open at the same time that the user can switch between. Each page will start at the Main Menu and then move on as stated above. To simplify this, I'm trying to build something similar to a web browser. The user can have multiple pages, tabs, or whatever open which are independent of each other and can switch between them at will
Scrolling between pages in ViewPager2 is where most of my problems have happened. Here is what I have tried so far:
Loading each fragment into a "holder" fragment - The Fragment disappeared when scrolling to another fragment.
Letting the Main Activity load the Main Menu Fragment without a "holder" fragment. This worked for scrolling between pages, but when I tap on a menu icon on any page, it changed the data on the first page.
I tried using SupportFragmentManager and ChildFragmentManager. I tried to mix the two with varied results. None of which create the desired behavior.
Am I using ViewPager2 as it was intended or is there something else that I should be using to accomplish what I'm trying to do?

Tabs in Android UI: Are tabs just to toggle display of different contents, or can we perform long operations on the click of tab header?

The idea I have of tabs is that they are used semantically to display different contents on the same part of the screen.
Now I think it implies that all the data that needs to be displayed should be there, and only a display of that tab's contents should take place when the user clicks a tab-header.
From Android Design guide,
Fixed tabs display all items concurrently.
If I am understanding this correctly (I am assuming concurrently means sharing the same itme), all items should be there, and the user clicking the tab headers should just toggle the display.
But does it make sense to do an internet search, and make a web service call etc., on the click of a tab-header, so that the response from the web-service etc. is displayed in the tab?

Close Button for Button - Possible?

I am making an app that has a couple list view menus that lead to a file display. When the user opens a file (in a webview), I want to create a tab bar so that they can quickly refer back to this file even after going back through the menu and viewing a different file. I planned on creating a fragment activity that housed a horiz scroll view that housed buttons that referenced the file that they viewed. Then, when they move on to a different file, they can just hit the tab and return to the file referenced on the tab.
Couple things:
-the tab bar, once created, needs to persist across activities until closed by the user
-the tab bar needs to refresh itself every time the user opens a new file
-it would be really nice to have a little close button (like the red x in the corner in apple stuff) on the tab buttons, so that the user can close individual tabs.
Is this possible?
any suggestions, tips, etc ?
Is android's built in tabs a better way to go than horiz scroll view with buttons?
thanks in advance

Transition when switching Activity out of SlidingMenu (J.Feinstein)

I am an android newbie and I am trying to create an Android App with three Activities: a Homescreen, a listview and a detailview.
I integrated J. Feinstein's Sliding Menu in my Homescreen and filled it with a ListView to display my different categories (Restaurants, Bars, Culture, whatever). When I click one of my List Items, the new Activity gets created and Pops up. However, I want the Activity to replace the old one while the SlidingMenu stays on top and then gently slides away. I saw this behaviour in the Example App but I cant quite find the bit of code that holds the answer to my question. Hope anyone can help :)
The sample app uses fragment transactions instead of starting new activities to change the content. As far as I know, that is the only way to do the two actions – close sliding menu and change content – simultaneously.

Android - Honeycomb - Action Bar tabs and fragments

I am creating an app for Android 3.0+ that uses the action bar with tabs for navigation. I have 2 tabs that each load a ListFragment:
Tab 1 Tab2
A B
C D
Where A & C are list items in Tab 1 and B & D are list items in Tab 2.
Currently if you select Tab2 and then item B a new ListFragment is loaded on top of the current list fragment in Tab2. Pressing back takes you back to the original Tab2 contents. However if you don't press back and instead select Tab1 you see Tab1's contents on top of the new content you loaded in Tab 2. So I am guessing there is a better way of doing this. I wanted to use multiple fragments in each Tab to reduce the code complexity in each tab (for instance the onListItemSelected handling). Is there another way to do that without using multiple fragments? I am also trying to just save state but I am not sure how to tell the difference from when the user clicks back (then I would want to restore state) and the user has selected tab 1 and then selects tab 2 again (i would want to restore state).
Thanks
I am having similar struggles with the complexity of fragments and tabs on the Action bar. It seems to me that android for tablets is still very much in its infancy and there are various issues (like yours and the issues I'm having) that will be addressed in the coming months. For now, I think you just have to handle some of those complexities yourself instead of relying on the Android framework.
To answer your first question more directly, I think you need to step back and think out the functionality before diving into the code. I can give you a potential solution (keep track of your fragments manually in the activity and simply add and remove fragment as necessary via the ActionBar.TabListener interface.
Also, if you want the user to be switching from one fragment to another like you are suggesting, perhaps the back functionality shouldn't be used. What happens if the user clicks on the tabs 10 times in a row. Do you want the back button to take the user back through all of those events? I think the back button should only be used when the navigation system is very sequential and "back" is an easy concept. Check out all the Google apps that use tabs to see what I'm talking about.

Categories

Resources