[Solved] Tab Example not running

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

[Solved] Tab Example not running

Postby Splotch » Thu Jun 18, 2009 10:38 am

Hi, I try to reproduce the example :
http://developer.android.com/guide/tuto ... idget.html

My project compiles but not running.

I post my code:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.me.android.tabtest;
  2.  
  3. import android.app.TabActivity;
  4. import android.os.Bundle;
  5.  
  6. import android.widget.TabHost;
  7.  
  8. public class Tabtest extends TabActivity {     
  9.     /** Called when the activity is first created. */
  10.     @Override
  11.     public void onCreate(Bundle savedInstanceState) {
  12.         super.onCreate(savedInstanceState);
  13.         setContentView(R.layout.main);
  14.        
  15.         TabHost tbh = getTabHost();
  16.         tbh.addTab(tbh.newTabSpec("tab_Class").setIndicator("Class").setContent(R.id.TabMenuClass));
  17.         tbh.addTab(tbh.newTabSpec("tab_Train").setIndicator("Train").setContent(R.id.TabMenuTrain));
  18.         tbh.addTab(tbh.newTabSpec("tab_Test").setIndicator("Test").setContent(R.id.TabMenuTest));
  19.     }
  20. }
  21.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <?xml version="1.0" encoding="utf-8"?>
  2.  
  3. <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
  4.         android:layout_width="fill_parent"
  5.         android:layout_height="fill_parent"
  6.         android:id="@+id/TabMenuHost">
  7.        
  8.         <LinearLayout
  9.                 android:layout_width="wrap_content"
  10.                 android:layout_height="wrap_content"
  11.                 android:orientation="vertical"
  12.                 android:id="@+id/LinearLayout">
  13.                
  14.                 <TabWidget
  15.                         android:id="@+id/TabMenu"
  16.                         android:layout_width="wrap_content"
  17.                         android:layout_height="wrap_content" />
  18.                        
  19.                 <FrameLayout
  20.                         android:id="@+id/FrameLayout"
  21.                         android:layout_width="wrap_content"
  22.                         android:layout_height="wrap_content">
  23.                        
  24.                         <TextView
  25.                                 android:id="@+id/TabMenuClass"
  26.                                 android:layout_width="wrap_content"
  27.                                 android:layout_height="wrap_content"
  28.                                 android:text="Class" />
  29.                                
  30.                         <TextView
  31.                                 android:id="@+id/TabMenuTrain"
  32.                                 android:layout_width="wrap_content"
  33.                                 android:layout_height="wrap_content"
  34.                                 android:text="Train" />
  35.                                
  36.                         <TextView
  37.                                 android:id="@+id/TabMenuTest"
  38.                                 android:layout_width="wrap_content"
  39.                                 android:layout_height="wrap_content"
  40.                                 android:text="Test" />
  41.                        
  42.                 </FrameLayout>
  43.                
  44.         </LinearLayout>
  45.  
  46. </TabHost>
  47.  
Parsed in 0.005 seconds, using GeSHi 1.0.8.4


I don't why it don't work and what's happen ?

My console log :

Code: Select all
[2009-06-18 11:35:04 - Tabtest] ------------------------------
[2009-06-18 11:35:04 - Tabtest] Android Launch!
[2009-06-18 11:35:04 - Tabtest] adb is running normally.
[2009-06-18 11:35:04 - Tabtest] Performing com.me.android.tabtest.Tabtest activity launch
[2009-06-18 11:35:04 - Tabtest] Automatic Target Mode: launching new emulator with compatible AVD 'Android'
[2009-06-18 11:35:04 - Tabtest] Launching a new emulator with Virtual Device 'Android'
[2009-06-18 11:35:04 - Tabtest] New emulator found: emulator-5554
[2009-06-18 11:35:04 - Tabtest] Waiting for HOME ('android.process.acore') to be launched...
[2009-06-18 11:35:25 - Tabtest] HOME is up on device 'emulator-5554'
[2009-06-18 11:35:25 - Tabtest] Uploading Tabtest.apk onto device 'emulator-5554'
[2009-06-18 11:35:25 - Tabtest] Installing Tabtest.apk...
[2009-06-18 11:35:38 - Tabtest] Application already exists. Attempting to re-install instead...
[2009-06-18 11:35:42 - Tabtest] Success!
[2009-06-18 11:35:42 - Tabtest] Starting activity com.me.android.tabtest.Tabtest on device
[2009-06-18 11:35:44 - Tabtest] ActivityManager: Starting: Intent { comp={com.me.android.tabtest/com.me.android.tabtest.Tabtest} }
[2009-06-18 11:35:44 - Tabtest] Attempting to connect debugger to 'com.me.android.Tabtest' on port 8639


If someone can help me ... Thanks.
Last edited by Splotch on Fri Jun 19, 2009 10:47 am, edited 1 time in total.
Splotch
Freshman
Freshman
 
Posts: 2
Joined: Wed Jun 17, 2009 5:30 pm

Top

Postby serkan.dogantekin » Thu Jun 18, 2009 9:54 pm

If you are extending TabActivity, then in the layout xml (which you use in setContentView method call)
- TabHost's id must be set as "@android:id/tabhost"
- TabWidget's id must be set as "@android:id/tabs"
- FrameLayout's id must be set as "@android:id/tabcontent"

Other than these, your code seems ok
serkan.dogantekin
Developer
Developer
 
Posts: 27
Joined: Thu Jun 04, 2009 6:12 pm
Location: Istanbul/Turkey

Postby Splotch » Fri Jun 19, 2009 10:46 am

thank you it works. :)
Splotch
Freshman
Freshman
 
Posts: 2
Joined: Wed Jun 17, 2009 5:30 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google [Bot] and 4 guests