Android Question [SOLVED]TabStrip with StateManager

Jorge M A

Well-Known Member
Licensed User
Longtime User
Hello,
how can I save the State of core views placed in the TabStrip using StateManager?
I am using the example of the tutorial "TabStripViewPager - Better ViewPager" project, I added an EditText to Page1 and a CheckBox to Page2. I added the module StateManager (with the necessary references), and I added the suggested code in Activity_Create and Activity_Pause, however I do not have the expected results.
Analyzing the StateManager, in the Sub SaveState code, it reports that the activity has only NumberOfViews = 1, and the cycle: For i = 0 To Activity.NumberOfViews - 1, prevents the execution of innerSaveState.
Thank you for your support.
 

Ricky D

Well-Known Member
Licensed User
Longtime User
You
Hello,
how can I save the State of core views placed in the TabStrip using StateManager?
I am using the example of the tutorial "TabStripViewPager - Better ViewPager" project, I added an EditText to Page1 and a CheckBox to Page2. I added the module StateManager (with the necessary references), and I added the suggested code in Activity_Create and Activity_Pause, however I do not have the expected results.
Analyzing the StateManager, in the Sub SaveState code, it reports that the activity has only NumberOfViews = 1, and the cycle: For i = 0 To Activity.NumberOfViews - 1, prevents the execution of innerSaveState.
Thank you for your support.
You need to show us code
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
Hello @Ricky D , Thanks for you support. I really think is not necessary cause i'm working with given sample code. I just want to know how can i save the State of core views placed in the TabStrip using StateManager.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Add a panel as the top parent of each of the tab pages layout files.
2. Save the states of the activity and each of the panels:
B4X:
StateManager.SaveState(Activity, "Main")
StateManager.SaveState(PanelOfFirstPage, "PanelOfFirstPage")
StateManager.SaveState(PanelOfSecondPage, "PanelOfSecondPage")
...
Follow the same process when you load the state.
 
Upvote 0

Jorge M A

Well-Known Member
Licensed User
Longtime User
Sorry @Erel, This is only "partially" working. "Page1" loose their data when I rotate the device. "Page2" seems to work ok.
Annex the test project, so do please check it when you have a chance.
Thank you.
 

Attachments

  • TabStripTest.zip
    14.3 KB · Views: 316
Upvote 0
Top