Android - Reading data from tabs / fragments - android

I'm working on an Android app that does nothing more then storing data in a SQLite database and displaying it.
Since I have a .NET background I started off developing the app with MonoDroid (C#). After developing the app with MonoDroid I thought it would be fun to redevelop it with Java and learn along the way.
In the original app I used a TabActivity and created 4 tabs to stucturize the data I want to save in a single table. Underneath the tabs I placed a button. A click on the button collects all data on the 4 tabs to store it, and it worked perfect.
Now developing with Java I noticed that the TabActivity is deprecated and I found out that I have to use fragments. I was able to create the tabs following this article. However, I am no longer able to read the data on the tabs. I searched online and tried the most ridiculous "solutions" for a couple days in a row now, and I start to doubt if the functionality I look for is possible.
Please advise me what to do! Is it possible to recreate this functionality using fragments? If so, can anyone give me some pointers?
If not, what would be the best way to approach this?
Thanks in advance!

Related

How to create and manage a multi tab Android app?

I'm trying to add multi tab functionality (browser like) to an already existent app, a mobile client for Netbox, and the goal is to implement a multi tab environment to manage more items at the same time.
This app is written in Kotlin, using android navigation (single activity) and MVVM.
Searching on the internet I didn't find a reliable solution, and I came up with an idea based on managing multiple instances of the main activity, because creating multiple instances it's quite simple.
If this solution can be considered good, I need to find a way to manage various instances to be able to switch between them, maybe with a navigation drawer.
If this solution it's unsuitable, every other idea is welcome.
See viewpager or viewpager2 ( Recommended ). https://developer.android.com/reference/androidx/viewpager2/widget/ViewPager2?hl=en

General android layout questions

I should begin by saying that I'm brand new to android development, although I have a good understanding of the fundamentals of java. That being said, I usually learn best by doing, so I'm writing an app for a campus magazine I work for and trying to learn through the process of making it.
At the top of the screen is a bar with two spinners labeled "issues" and "sections," which allow the user to filter the articles shown to only those in the respective issue / section. The rest of the screen is taken up by what I will describe as a vertically-oriented gallery, which shows the headline for each story underneath an image associated with it. The user can then "flip" through the stories in the magazine by scrolling through the "gallery." Selecting one of the stories will open the full story up in ViewPager.
I have two main questions at this point:
1) Initially, I planned to place the "issues" and "sections" spinners in the ActionBar. However, as I understand it, ActionBars are not displayed to users using Android 2.x. Given that these elements are critical to navigating the app, and that a majority of android users are still using 2.x, this seems unacceptable. As a result, I'm using an ActionBar-less theme and essentially drawing my own action bar via a linear layout on top of my main activity. Am I correct in my understanding that ActionBars do not display on Android 2.x devices? If so, am I correct in including my "tool bar" as a part of the main activity, or is there a better way to implement it? (Perhaps as a fragment? I don't really understand how those fit in yet...).
2) I am aware that the gallery widget is deprecated, so obviously I'm not going to use it. What alternative widgets would best achieve the same visual goal of having the user "flip" through the stories in the magazine by scrolling through the widget? Is there a way to animate a ListView to achieve this goal?
Again, any help - particularly which helps me to understand the wider issues involved here - will be greatly appreciated.
Thanks in advance.
You can use ActionBarSherlock - it is compatible down to Android v 1.6.
ViewPager might help you

Correct Way To Implement A Tabbed Bar

I have been browsing the web for a while now and looking at different examples of how to implement a tab bar.
The problem I am having is deciding the correct approach to creating this feature. The option that seems most used is to have one main activity called MainActivity or something and using fragments as the tabs. This is all well and good and I have created an application like this fine.
The problem I am having is I am in two minds as to whether this is the right way to go about it as coming from an iOS development background it just doesn't seem right due to these tabs having different functions.
Any pointers would be great.
EDIT I have also looked into ActionBarSherlock but couldn't get to use it in a project as it kept coming up with errors and I couldn't find a thread that sorted the problems I was having out.
Disco
You should be using fragments, yes. There is an example of how to do it here: http://developer.android.com/guide/topics/ui/actionbar.html#Tabs
This "only" works with Tabs that are part of your Actionbar, though. Shouldn't be too much of a problem, because they usually should be part of your Actionbar. You can also manually move the tabs if you're not content with their location, or roll your own buttons that look like tabs.
Keep in mind that tabs in Android aren't quite the same beast as the tab bar is in iOS. They look similar and behave similar, but there are subtle conceptual differences in how they are supposed to be used. Don't use them for your basic app navigation, but rather for switching between similar "things".
If you want to employ this on device pre-3.0 though, you will have to use ActionBarSherlock. It does work fine and we're using it in several projects, so if you're having problems integrating it I suggest creating a new question for that, I'll be happy to help.

Implement Windows Phone 7 Pager (Tab switching, pivots, panorama etc) UI in Android App?

Can someone help me figure out how to code in Windows Phone 7 like Pager UI into an Android app?
I am refering to the behavior of switching between several tabs(or pages if you will).
I know how to use View Pagers, but im unable to figure out the logic to do this.
For example the switching between artists, albums etc implemented in https://play.google.com/store/apps/details?id=app.odesanmi.and.wpmusic
Or the settings implemented in Launcher 7
https://play.google.com/store/apps/details?id=info.tikuwarez.launcher3&feature=more_from_developer#?t=W251bGwsMSwxLDEwMiwiaW5mby50aWt1d2FyZXoubGF1bmNoZXIzIl0.
Very Specifically i would like to know to know how to switch those tab names along with the actual page. I was wondering if this might even be possible with two Viewpagers, but im not sure of how to synchronize them, if such a thing is even possible.

Convert existing app to use Fragments

I am new to Android and have an app on the Market that I would like to convert to use Fragments so it could take advantage of the tablet in landscape mode and have both activities side by side. All of the examples I can find out there use a listview with a image or text in the right column and uses the FragmentList class. My app has an Activity that has buttons and depending on what buttons or spinners they select it then displays another activity. Can anyone recommend a tutorial or article on how to do this? I have read the Google blog but found it confusing and wasn't sure how to use it to modify my existing code. Any help would be appreciated.
This is a good tutorial http://portabledroid.wordpress.com/2011/04/19/programmatic-and-layout-fragments/

Categories

Resources