Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Best way to implement multiple pages in Android Studio

 
Eric Sweeten
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the best way to implement multiple pages in Android Studio?

I created a Lottery application in regular Java and I want to convert it for use in Android. I have too many GUI components for one page, and so I want to separate it into multiple pages. Should I use multiple activities or a viewpager or how should I go about doing it? I am brand new to Android Studio.

This is a screenshot of my application:



I want one page to ask information such as amount of numbers, how often, how long, bonus number option, etc., another page to ask for the numbers on the custom ticket (or to select "random"), another page to fill out the payout amounts, and finally some sort of pop-up with a loading bar that will show it's calculating the statistics.

Any help is greatly appreciated!
 
Tim Moores
Bartender
Posts: 3134
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's hard to say without knowing what the flow through the app will be, but my gut feeling would be to use a viewpager rather than multiple activities. With activities you would have to deal with their lifecycle events, making sure that data is synced across all of them. The viewpager lifecycle would be much simpler.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about a TabHost (under Containers in the XML design view)? That would keep you within the same Activity, assuming all the data is closely related.
 
Eric Sweeten
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Tkatch wrote:How about a TabHost (under Containers in the XML design view)? That would keep you within the same Activity, assuming all the data is closely related.


Thanks for the advice. I tried implementing it but I am having problems. Android Studio is altogether a huge headache from what I can see. When I import the TabHost, it's now saying I need some sort of TabWidget or something, so it's not working. I tried looking for help online and did what people said, but nothing's working.
 
Tim Moores
Bartender
Posts: 3134
50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TabHosts were an early way in the Android API to achieve something like this, but they've sort of fallen by the wayside. For a new project I wouldn't recommend them.

Android Studio certainly had a learning curve, especially if you're learning Android programming at the same time. You might consider doing without an IDE for the time being, using just an editor and Gradle until you're a bit further down the road.
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't know tab hosts were like that. I just saw them on the side and thought to remember them if needed.

It's not just Android that's hard, the terminology itself is rather confusing, and so many examples on the Internet use redundant code. It's hard to find the signal inside all that noise!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic