Need help with tabbed layout

by Dave Williams » Fri, 25 Feb 2011 12:57:53 GMT

Sponsored Links
 'm new to Android development so please bear with me.  I have created
an app in WebOS and I'm keen to try and re-create for the Android
platform. I have tried to follow the tutorial for creating a tabbed
view and to some extent I have succeeded. However, the problem that I
am having is that when I switch from tab to tab any text or graphics
is overwritting the tab elements and not displaying below the tabs
themselves. I'm sure I've done something stupid that is easy to fix.

Here are the files that I have. I have my main class which extends
TabActivity. The code is as follows:

*package com.dtwconsulting.golfcaddie;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.widget.TabHost;

public class GolfCaddie extends TabActivity {
/** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState) {

* * Resources res = getResources(); // Resource object to get
TabHost tabHost = getTabHost(); // The activity TabHost
TabHost.TabSpec spec; // Resusable TabSpec for each tab
Intent intent; // Reusable Intent for each tab

* * // Create an Intent to launch an Activity for the tab (to be
intent = new Intent().setClass(this, MainActivity.class);

* * // Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("main").**setIndicator("Main",

* * // Do the same for the other tabs
intent = new Intent().setClass(this, PlayersActivity.class);
spec = tabHost.newTabSpec("players").**setIndicator("Players",

* * intent = new Intent().setClass(this, CoursesActivity.class);
spec = tabHost.newTabSpec("courses").**setIndicator("Courses",

* * tabHost.setCurrentTab(0);

* * }

* * public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(**menu, menu);
return true;

My R.layout.splashmain XML code is as follows:

*<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android=""
<TabWidget android:id="@android:id/tabs"
android:layout_height="fill_**parent" />
<FrameLayout android:id="@android:id/**tabcontent"

Other Threads

1. how to promote my app?

What's the effective way to promote an app?

What's your experience?



2. BT Voice Dial

After talking in the wrong mailing list, lets try again ^^.

I am planing on buying a HTC Magic running Cupcake 1.5. My primary
requirement is having a working voice dial (so no interaction using
the screen because the phone will be in my pocket or bag while I am
driving). I understand that this function is possibly disabled because
the dialer is not ready.

Then I wonder the following:
- Is it completely disabled on the Magic? Or does it have the input
popup after speaking the name?
- Will this be fixed in the next release? 1.6? When?
- Can the dialer be replaced by a user program? With the voice input
framework (I read about it somewhere) it should be possible to cook up
an alternative, or am I missing something?

Berend Dekens


3. V8 engine interface to boost Android speed?

4. bluetooth music streaming

5. xWallpaper 1.0 released

6. Porting Dalvik VM on non LINUX OS

7. GPS being activated and disabled within Maps app