views:

187

answers:

2

What's the best way to implement an Android Market-like tabbar (Apps/Games/Downloads)?

alt text

It would be great if I could use TabHost, but I believe it doesn't allow this level of customization.

+2  A: 

It's possible to do using TabHost. Even better, you can find a fully functional example of how to do it here: http://code.google.com/p/androidtabs/

Cristian
+1  A: 

As Cristian said, it's definitely possible using a TabHost, and you don't even need to use the androidtabs code that he links to. As of SDK level 4 (i.e. Android 1.6) you can pass a View to TabHost.TabSpec.setIndicator(), which will allow you to completely control the look of the tabs.

However, tapping either of those buttons in the Market opens up a new Activity, and as such, using simple Buttons might more closely reflect that behaviour than a TabHost would.

In the event that you need to support 1.5 as well, you could check out the zip archive from this post. It contains TabHost etc. from Android 1.6. Copying this into your project should work, even on Android 1.5. You'll then have setIndicator(View v) available to you.

benvd
Thanks Kilnr. Unfortunately I have to target 1.5 devices too. I guess I can use the default style for 1.5 devices, and make use of setIndicator in newer versions.
hgpc
Updated my answer for 1.5
benvd