Android Question Tabhost hides when I start an activity

grafsoft

Well-Known Member
Licensed User
Longtime User
Hi,

this is my code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("Main")
   th1.Left=0
     th1.Top=0
   th1.Width=100%x
   th1.Height=100%y
   th1.AddTab ("Kontakte","first")
   th1.AddTab ("Galerie","gallery")
   th1.AddTab ("CRM","crm")
...
end sub

Sub th1_tabchanged
   If th1.CurrentTab=0 Then
     ' Activity.LoadLayout ("main")
   Else If th1.CurrentTab=1 Then
     StartActivity ("Galerie")
   Else If th1.CurrentTab=2 Then
     StartActivity ("crm")
   End If
End Sub

When I start an activity, the tabhost disappears. When I go back, it is here again. I want it to stay.

Thank you

Peter
 

DonManfred

Expert
Licensed User
Longtime User
if you start an activity then you always leave the current one.
You already have loaded all layouts... first, galery and crm

B4X:
Sub th1_tabchanged
  If th1.CurrentTab=0 Then
    ' Activity.LoadLayout ("main")
    ' First (layout first) is now active tab
  Else If th1.CurrentTab=1 Then
    ' galery (layout galery) is now active tab
  Else If th1.CurrentTab=2 Then
    ' crm (layout crm) is now active tab
  End If
End Sub
 
Last edited:
Upvote 0

grafsoft

Well-Known Member
Licensed User
Longtime User
Thank you, now I understand. I just do not want to have too much code in one file - hard to reuse. A form with another form as parent would be nice.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…