Bonjour,

Je tentais de me familiariser avec le tabActivity en reprenant le code de google.

Avec ma veine celui ci me provoque une erreur.
Je ne comprends pas car j'ai repris les base de l'exemple :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 
public class Launcher extends TabActivity {
    /** Called when the activity is first created. */
 
	private void buildTabs(){
		Resources res = getResources(); 	// Resource object to get Drawables
        TabHost tabHost = getTabHost();  	// The activity TabHost
        TabHost.TabSpec spec;  				// Reusable 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, SoundActivity.class);
 
        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("sound").setIndicator("Sound",res.getDrawable(R.drawable.ic_tab_sound)).setContent(intent);
        tabHost.addTab(spec);
 
        // Do the same for the other tabs
        intent = new Intent().setClass(this, VideoActivity.class);
        spec = tabHost.newTabSpec("video").setIndicator("Video",res.getDrawable(R.drawable.ic_tab_video)).setContent(intent);
        tabHost.addTab(spec);
 
        intent = new Intent().setClass(this, SettingActivity.class);
        spec = tabHost.newTabSpec("setting").setIndicator("Setting",res.getDrawable(R.drawable.ic_tab_setting)).setContent(intent);
        tabHost.addTab(spec);
 
 
        tabHost.setCurrentTab(0);
	}
 
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        buildTabs();
    } 
 
}
main.xml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
 
<?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="wrap_content">
 
	    <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp">
	        <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" />
	        <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" />
	    </LinearLayout>
</TabHost>
J'ai bien créé les classes videoActivity etc...
Celles-ci sont bien dans le magnifest.xml

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="main.GUI"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar">
        <activity android:name=".Launcher"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
		<activity android:name=".SettingActivity"
                  android:label="@string/setting_activity_name">
        </activity>
        <activity android:name=".VideoActivity"
                  android:label="@string/video_activity_name">
        </activity>
        <activity android:name=".SoundActivity"
                  android:label="@string/sound_activity_name">
        </activity>
    </application>
    <uses-sdk android:minSdkVersion="3" />
 
</manifest>
Au début je pensais que l'application plantais à cause d'un bloc dans buildTabs mais elle pense maintenant dès le début.

Que faire??

P.S : je suis sur la 1.5