• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Best way to implement multiple pages in Android Studio

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 598
26
Oracle Notepad Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic