1

I'm creating an app that takes user entered information from multiple activities and gives them a result based off these:

Activity Survey Activity Recap Activity Result

For each survey, there are between 7-10 question activities, and a result activity. Continue button goes to next activity.

 bContinue.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (validateData()) {
                    Intent next = new Intent(getApplicationContext(), SurveyThree.class);
                    startActivity(next);
                } else {
                    //Don't
                }
            }
        });

For now this is fine, but as I continue developing, I'll be adding dozens more of these survey types, each with 7-0 activities, leading to hundreds of activities.

What would be the most performance and user-friendly way to (repeatably) deliver a series of questions like this in separate views without creating a huge amount of activities?

jon.bray.eth
  • 527
  • 6
  • 13

1 Answers1

2

Creating more number of Activities is not suggested for your requirement. Instead, you can use ViewPager. Learn more about ViewPager and Fragments, there are lots of material available on the internet. Here you need to customize a few things according to your requirement.

Maintain a list of questions and pass the list to viewpager to let it create the dynamic number of fragments you need. This helps you in future when you add new questions.

You need to create fragments for your questions, similar type of fragments for similar kind of questions i.e., template kind of fragments. When a similar question needs to be added just use the existing fragment by changing the content.

Viewpager by default comes with a swiping feature you can disable it. Learn How