TabHost: How to change a title?

Jost aus Soest

Active Member
Licensed User
Longtime User
I need to change the title of the current tab, e. g. something like
B4X:
Sub txtBez_TextChanged(Old As String, New As String)

  Dim TabCaption As String

  If New.Trim = "" Then
    TabCaption = "Spieler " & MainTab.CurrentTab
  Else
    TabCaption = New.Trim
  End If
  MainTab.Title(MainTab.CurrentTab) = TabCaption

End Sub
so it can reflect in real time, what I'm typing in an EditText.

How is this possible?

I've already checked the TabHostExtras-Library, but without results.
 
Last edited:

Jost aus Soest

Active Member
Licensed User
Longtime User
Alternatives?

How can i change the tabs of a tabhost, when there is also no RemoveTab method?
Will it be possible in the (near) future?

Or how would you accomplish now the following task:
I'm developing a digital score card (for calculating the victory points of a board game, but this doesn't matters), where every tab shall represent one player (and tab 0 the summary). After game end it's necessary to change the player names befor beginning a new game.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
I think it'd be easiest to remove the existing TabHost and create then add a new TabHost for each new game.

I'll try and make time to look into whether the TabIndicator text can be changed and post again with my findings.

Martin.
 
Upvote 0

Jost aus Soest

Active Member
Licensed User
Longtime User
Thank you Martin!

I think it'd be easiest to remove the existing TabHost and create then add a new TabHost for each new game.

I've feared such an answer...
What's the easiest way to accomplish this?

I'll try and make time to look into whether the TabIndicator text can be changed and post again with my findings.

That would be great!:icon_clap:
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
What's the easiest way to accomplish this?

Are you using the Designer to add a TabHost to your Activity, then programmatically adding TabContent?

If so then the logical way would i think to create and add your TabHost entirely in code - programmatically.
You'd need to write code (on top of what you already have written) to Initialize the TabHost before using Activity.AddView to add it to your Activity.

A TabHost has a RemoveView method that you can use to remove it from your Activity.

Once you have removed it just re-use your existing code and start again:
Initialize and add a new TabHost to your Activity.
Add the TabContent.
Tweak it with TabHostExtras.
Finally remove it when it's finished with.

I've updated TabHostExtras to version 1.6 adding a new method to enable you to set the text of individual tabs:

http://www.b4x.com/forum/additional-libraries-official-updates/11056-tabhostextras.html#post61757

Martin.
 
Upvote 0

Jost aus Soest

Active Member
Licensed User
Longtime User
Thank you very much!

I've thought that TabHost.RemoveView is for removing a TabHost-child (i. e. a tab-content). :BangHead:
Now this is much clearer!

But with your new version of TabHostExtras my wishes came already true! Together with setTabVisibility2 I'm now able to configure (and change in run time!) the tabs like I want.
:sign0098:
 
Upvote 0
Top