Tab Host "Reset"

noist

Member
Hello all,

I created a TabHost, that opens a different panel for each tab. If changes are made within such a panel, they remain, also if the tab is changed.

I want to "reset" the panels whenever a tab is changed, so that it always shows the tab the same way it was before any changes to it were made.

How do I do that?
I tried TabHost_TabChanged, but that doesn't really seem to do anything.
 

yttrium

Active Member
Licensed User
Longtime User
To begin with, you're going to need to make some kind of save-state for what the original screen was, and then set the screen each time the tab is changed.

Are you having trouble with the actual tab change detection, or the reset?
 
Upvote 0

noist

Member
Well, I tried this:

Sub TabHost_TabChanged

Label1.Text = "This is page 1"
Label2.Text = "This is page 2"

'End Sub

Basically there aren't many Views in the Panels, so it wouldn't take much coding to set it back to how it was before, but I don't know how to cause that by "changing tabs".
The above doesn't work.
 
Upvote 0

mangojack

Well-Known Member
Licensed User
Longtime User
Hello noist .. maybe try this

B4X:
Sub TabHost1_TabChanged
         
   Select Case TabHost1.CurrentTab
      Case 0      
         'reset code
      Case 1   
         'reset code         
      Case 2                        
         'and so on
   End Select
   
End Sub

Cheers mj
 
Upvote 0

noist

Member
Nothing in particular, just that nothing happens when I change the tab.

I can post the whole code for an example here:


No Msgbox appears when I change tabs. Same if I add views to the layouts and try to do something with them.

What am I doing wrong?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…