Create Forms on Android and how to treat them

2

I'm designing an application on 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 several activities that through buttons back and forth through the sections ... This is when I have several questions:

Is it worthwhile to do everything in the same activity and change the fields that I am showing and enabling the fields you need or different activities ...?

I would also like to add that when I passed back and forth the fields that I had previously filled in that were self-filled, here I have another question:

Is it worthwhile for me to create something like a "Form" class that has attributes for each of the different fields and that I am going through activities or whatever the object is organized and when opening the activity get the object the attributes of the fields?

    
asked by Miguel A. 05.04.2016 в 16:07
source

2 answers

0

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

or you can make the sections visible according to advances in your application:

vistaApartadoB.setVisibility(View.VISIBLE);

While the section you do not need you can make it invisible and collapse the view:

vistaApartadoA.setVisibility(View.GONE);

and all the sections can be in the same Layout.

    
answered by 06.04.2016 / 00:22
source
0

For what you comment it seems that it could help you to do a wizard .

You can save yourself some work and use Android Json Wizard

You only 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 go grouping them 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",

    }
}
    
answered by 05.04.2016 в 16:20