deveLost
deveLost

Reputation: 1171

Android Two layout for one activity

I have a form, and I have chosen to divide it in two steps.

To do it, I created two layouts for a same activity. When the user complete the first form, I call the second layout with :

setContentView(R.layout.activity_form2);

The problem is, if the user wants to come back at the first step of the form, it's not running, because he comes back to the previous activity.

Is it correct to do that, or I need to use fragment?

Otherwise, how can I do to come back on the previous layout, and not the previous activity?

Upvotes: 2

Views: 1616

Answers (1)

Raghunandan
Raghunandan

Reputation: 133560

Never set different layout's for the same Activity. You can navigate to a different Activity or you could use Fragments.

Layout is set to the Activity and when you click back button Activity is popped from the back stack and previous Activity in the stack takes focus. So setting different layouts for the same Activity is not a good choice.

Upvotes: 4

Related Questions