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. Autofocus callback not happening on HTC Desire HD

Hi all,

I'm facing a problem with a camera application. The problem is that
after I call autoFocus(callBack), the device doesn't callback.

In the debug logs it's clear that the command was successful and the
autofocus has started:

02-06 15:40:44.305: DEBUG/QualcommCameraHardware(1218): autoFocus E
02-06 15:40:44.305: DEBUG/QualcommCameraHardware(1218): autoFocus X
02-06 15:40:44.315: DEBUG/QualcommCameraHardware(1218): runAutoFocus E
02-06 15:40:44.315: DEBUG/QualcommCameraHardware(1218): af start (fd
54)
02-06 15:40:44.535: INFO/CameraService(1218): [Camera KPI] 1st preview
frame

After "af start (fd 54)" the method set as callback is never called.

This DOESN'T always happen, it happens just in some cases, mainly when
I try my best to make the autofocus hard (by placing a finger on the
camera and remove it before autofocus completes).

Does anyone have a suggestion? My application depends on the callback
to take the picture, if I don't get the callback it never takes the
picture.

Thank you all for your support,

Marco

-- 

2. Checkout transitioning to monthly payouts?

There is a thread going on the Checkout support page about the sudden
and unexpected transition to monthly payments:
http://www.google.com/support/forum/p/checkout-merchants/thread?tid=2788f3abcf2e45aa&hl=en&fid=2788f3abcf2e45aa00049bfc2ac4eb15

I have thoroughly searched my email and can't find any notice from
Google about this change.  There is also nothing on the Android blog
or the Checkout blog.

Developers should have been notified via multiple avenues.  At this
point Google really needs to issue a formal apology to developers, and
either offer developers the option to keep daily payouts, or delay the
transition for a month to allow developers who have been living day to
day to save up.

-- 

3. Paging Pak Kris

4. [WTA] Iquran Pro

5. No option to download the API documentation in the Android SDK and AVD Manager

6. binary attributes

7. [Wts] desire hd, nexus one, Galaxy s, HD2,micro sd