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.app.TabActivity;
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. */
@Override

public void onCreate(Bundle savedInstanceState) {
super.onCreate(*
*savedInstanceState);
setContentView(R.layout.**splashmain);

* * Resources res = getResources(); // Resource object to get
Drawables
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
reused)
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",
res.getDrawable(R.drawable.ic_**tab_main))
.setContent(intent);
tabHost.addTab(spec);

* * // Do the same for the other tabs
intent = new Intent().setClass(this, PlayersActivity.class);
spec = tabHost.newTabSpec("players").**setIndicator("Players",
res.getDrawable(R.drawable.ic_**tab_players))
.setContent(intent);
tabHost.addTab(spec);

* * intent = new Intent().setClass(this, CoursesActivity.class);
spec = tabHost.newTabSpec("courses").**setIndicator("Courses",
res.getDrawable(R.drawable.ic_**tab_courses))
.setContent(intent);
tabHost.addTab(spec);

* * tabHost.setCurrentTab(0);

* * }

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

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

*<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/**tabhost"
android:layout_width="fill_**parent"
android:layout_height="fill_**parent">
<TabWidget android:id="@android:id/tabs"
android:layout_width="fill_**parent"
android:layout_height="fill_**parent" />
<FrameLayout android:id="@android:id/**tabcontent"
android:layout_width="fill_**parent"



Other Threads

1. Reg. accessing the external files

Consider this scenerio:
The end user copies a bunch of text files onto his android every week.
My application which has to do some analysis on this text files and
show the results to the user.

Can my application access files anywhere in the file system of
android? If NO, what would be the location where the user is supposed
to copy the files to or any alternate solution ? Because the user
copies the files periodically on to Android. My application is
supposed to do analysis and display the results.

Please Help. I'm a newbie.

-- 

2. PhoneFactory

Hi,

-- 

3. Best practices for integrated (context-sensitive) help?

4. license question about bootchart.c

5. AssertionError on android.util.Xml.parse

6. WebView wait for images

7. Best practices for integrated (context-sensitive) help?