0

Using Fragments, i want to restore the UI state if UI elements are created dynamically at Run-time. Like below is my layout image,

enter image description here

Above, is my default Layout with one Edit Text box. And buttons are created dynamically at Run-time. On click ADD button, it will add one more Edit Text box in the layout.

Like below, if click twice ADD button, it will be ,

enter image description here

I want to store UI state in BackStack, So if i will switch to another Fragment and get back to same(Dynamic Layout), it will shown the same UI state. But it doesn't, it is showing the default Layout with one Edit Text box.

How to maintain UI state ? If created dynamically .

sandeep gupta
  • 301
  • 1
  • 3
  • 14
  • with which code are you "switching back" to the "dynamic-layout" fragment? are you using replace method for the dynamic-fragment by any case? you should pop those fragments you don't need anymore with FragmentManager.popBackStack() in order to return to the one you want – FrancescoC Mar 20 '15 at 08:23
  • you should use onSaveInstanceState() and onRestoreInstanceState() method for storing activity states. – Arun Kumar Mar 20 '15 at 08:33

0 Answers0