Create forms on Android and how to treat them

'm designing an application in Android and I need to create a form with many fields, my idea is to make a form with different sections and instead of doing all the sections in the same activity with a vertical scroll, I want to create one or more activities that by using back and forward buttons through the sections... This is when several doubts arise:

Is it worth doing everything in the same activity and changing the fields I'm going to showing and enabling the fields you need or different activities...?

I would also like to add that when I pass back and forth the fields that I have already filled previously that I auto-filled these, here I have another doubt:

Is it worth it for me to create something like a "form" class that has attributes for each of the different fields and that I go between activities or whatever that object organizes and at the time of opening the activity get the attributes of the fields from the object?

 2
Author: Miguel A., 2016-04-05

2 answers

The simplest thing would be to create several activities, I don't like this idea; what I would do is precisely what you comment, a form class that contains all the sections and create other classes that extend from this parent class from which they inherit certain sections.

Or you can make the sections visible according to progress in your application:

vistaApartadoB.setVisibility(View.VISIBLE);

While the section you don't need you can make it invisible and collapse the view:

vistaApartadoA.setVisibility(View.GONE);

And all sections can be in the same Layout.

 0
Author: Jorgesys, 2016-04-05 22:22:16

From what you comment it seems that you could use to make a wizard.

You can save yourself some work and use Android Json Wizard

You just need to add the dependency to your pom (if you work with maven)

<dependency>
    <groupId>com.github.vijayrawatsan</groupId>
    <artifactId>android-json-form-wizard</artifactId>
    <version>1.0</version>
</dependency>

The trick is to generate a json with your data that you need to load and group it by "steps"

{
    "count":"2",
    "paso1":{
        "fields":[
            {
                "key":"nombre",
                "type":"edit_text",
                "hint":"Enter Your Name",
                "value":"Vijay"
            }
        ],
        "title":"Paso 1 de N",
        "next":"paso2"
    },
    "paso2":{
        "fields":[
            {
                "key":"name",
                "type":"edit_text",
                "hint":"Algun dato",
                "value":"Dafult"
            }
        "title":"Paso 2",

    }
}
 0
Author: jasilva, 2016-04-05 14:20:22