Can't get tabs to work with intents

by jouke » Mon, 27 Jul 2009 06:44:58 GMT


Sponsored Links
 ello all,
I try to make an plication with tabs using intents and activities to
populate the different tabs. The layout seems OK but as soon as I hit
a spinner on a tab populated by an Activity (Intent) it crashes (due
to a null pointer). I made a small test application to reproduce the
error.
I'm sure I do something wrong but I can't seem to find out what.
Thanks a lot for any help,
Jouke

=== source (partly) ===

package com.jouke.test;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;

public class Test extends TabActivity {
private TabHost mTabHost;

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);
mTabHost = getTabHost();

mTabHost.addTab(mTabHost.newTabSpec("Tab1")
.setIndicator("Tab1")
.setContent(R.id.tab1));
Intent tab2 = new Intent(this.getApplicationContext
(),tab2.class);
mTabHost.addTab(mTabHost.newTabSpec("Tab2")
.setIndicator("Tab2")
.setContent(tab2));
}
}

----

package com.jouke.test;

import android.app.TabActivity;

public class tab1 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);
}
}

----
package com.jouke.test;

import android.app.TabActivity;

public class tab2 extends TabActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab2);
}

----
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jouke.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/
app_name">
<activity android:name=".Test"
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=".tab1">
<intent-filter>
<action android:name="android.intent.action.EMBEDDED" /
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".tab2">
<intent-filter>
<action android:name="android.intent.action.EMBEDDED" /
<category
android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="3" />
</mani



Other Threads

1. A problem about -rpath-link

I am learning Anroid development, trying to write native C program.
I am using code sourcery g++ lite to compile and link my program, When
I tried to link my program dynamically, I met a problem.

I've pulled /system/lib from android emulator to my PC c:\androidlib
when link , I need to pass this path to -L and -rpath-link option.
-L "c:\androidlib" works.
but
-rpath-link "c:\androidlib" didn't work!!

I've tried in many forms such as:
-rpath-link "c:/androidlib"
-rpath-link "\c\androidlib"
-rpath-link \driver\c\androidlib"
None of above makes the linker know the correct path. How could I
solve this problem??

Any suggestion would be greatly appreciated(aside using -static to
avoid dynamic link).

-- 

2. Audio mixing

When there are multiple media players trying to play the audio/audio-video
files together, audio gets mixed and played out. Could someone clarify
whether this is a feature or a bug.

Usecase:
1. Play an audio file in the background using player 1
2. Invoke player 2 and select an audio-video file for playback

Result: Audio of both audio file and audio-video file gets mixed and played
out.

--~--~---------~--~----~------------~-------~--~----~

3. spinner question: how to detect the selection of an already selected item?

4. eclair-porting problem

5. tentang AP2SD di huawei

6. OOT: Thanks, Root Miley Boot Loader 7.8

7. onSharedPreferenceChanged() Not Called in Live Wallpaper (WallpaperService) Engine