3

I am using ViewPager to show the multiple views of the form, like name and email on first view and rest on others.

Now the problem is:

  • Enter Data on page 1 navigate to page 2 and then to page 3.
  • come back to page 1 the data is not there.

I have a save button on the last page so I also need a way to retrieve the data from other pages there.

If I can get a way I can save the data on page 1 when it is changed to page 2 like onDestroy method on activity.

Is ViewPager inappropriate for my purpose here?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Aashish Bhatnagar
  • 2,595
  • 2
  • 22
  • 37

2 Answers2

3

I have implemented something similar in my GitHub project: View Pager Form

Ashwin
  • 7,277
  • 1
  • 48
  • 70
0

I think ViewPager is fine for this purpose. All you need to do is to save data entered in first and second fragments to your parent Activity and fetch it when you hit Save in your last fragment.

EDIT: Check THIS and THIS related SO questions

Community
  • 1
  • 1
Evos
  • 3,915
  • 2
  • 18
  • 21
  • I am using the V4 support library here so how can I save data to the parent activity as the user swipes between views – Aashish Bhatnagar Feb 02 '13 at 09:42
  • This doesn't explain persistence between page swipes at all? – G_V Dec 03 '14 at 08:48
  • @G_V Yes it is not, but this problem was solved. Plus it's a bit obvious - fragments are destroyed when they off the offscreen limit, so by default ViewPager are not persistent. – Evos Dec 12 '14 at 23:46
  • I don't think we're using the same definition of persistence here. – G_V Dec 15 '14 at 08:02