-3

I am new to android and I want to develop a multi page sign up form. I want to know that I should use one activity for each page or it is a better approach to use fragments as I need to keep all data from each page to submit in database finally. Thanks

S S abbasi
  • 29
  • 1
  • 6
  • Possible duplicate of http://stackoverflow.com/questions/20306091/dilemma-when-to-use-fragments-vs-activities – Farshad Jul 06 '16 at 23:40

1 Answers1

1

This was a topic covered at Google I/O this year in a talk called What the Fragment.

The basic rule is that if a feature is meant to be reused along with split mode in landscape or tablet, then definitely use a fragment.

If the code is a reusable bit of functionality that may show up as a dialog or functionality in an other Activity then use a fragment.

Something that is discouraged is the use of multiple fragments to piece together an activity. I've seen a fragment with nothing but a button embedded in multiple activities. That's not good.

There is some discussion around how useful fragments are. Lyft came up with an alternate that uses views, called Scoop. If you want to swap a lot of Views, look in to that definitely.

For your need, the answer depends on how complex each for is. If there are a lot of fields on each form, with complex validation logic I would put it in an activity. Juggling fragments can be tricky if the users can skip bank and forth in the form. If the forms and interaction with them if simple, use fragments or even hidden views.

Ali
  • 12,354
  • 9
  • 54
  • 83