Tabhost is making me crazy

marcel

Active Member
Licensed User
Longtime User
Hi,

I have the following code copied from the tabhost example (including pictures and layout files).

B4X:
   Activity.LoadLayout("main")
   Dim bmp1, bmp2 As Bitmap
   bmp1 = LoadBitmap(File.DirAssets, "ic.png")
   bmp2 = LoadBitmap(File.DirAssets, "ic_selected.png")
   
   TabHost1.AddTabWithIcon("Name", bmp1, bmp2, "page1") 'load the layout file of each page
   TabHost1.AddTab("Color", "page2") 
   TabHost1.AddTab("Animal", "page3")

But for some reason I never get a tab with an icon??? See attached example
 

Attachments

  • tabhost.png
    tabhost.png
    32.7 KB · Views: 305

marcel

Active Member
Licensed User
Longtime User
More info.

On my device it won't work but in the emulator it does. This is os 2.2 and on my device I have 4.0.3.

Do I need to install something so that this work??
 
Upvote 0

marcel

Active Member
Licensed User
Longtime User
More info.

On my device it won't work but in the emulator it does. This is os 2.2 and on my device I have 4.0.3.

Do I need to install something so that this work??

Found it :) It had to to with the Manifest file. :(
 
Upvote 0

marcel

Active Member
Licensed User
Longtime User
Could you please post your solutions for other users.
.

Sorry, forgot it.

I found a line in the manifest editor (see below)

B4X:
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="14"/>

I removed the part android:targetSdkVersion="14" because I expected that this was the problem. And it worked ;)

I still do not know why. But I expect that the targetSDK did not match??
 
Upvote 0

marcel

Active Member
Licensed User
Longtime User
Starting from Android 4 the TabHost will only show icons if there is no text. This is how the new style looks. By removing the targetSdkVersion from the manifest editor you are using the old style.

Ok, Thanks. Well I like to oldstyle more :)
 
Upvote 0
Top