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. Customize Gallery to show a fixed number of items at all times

Is there a way to customize Gallery to show a fixed number of items at
all times?
For example, if item0 is in the center and we have 5 items in the
gallery, I would like to show item4, item0, and item1. The current
behavior will only show item0 and item1.

Thanks.
David

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

2. ListAdapter transformation

Hi all,

  I would like to transform the contents of one of the fields of a
databade before they get printed in each of the rows. For example, I
have an integer field that can be 0 or 1 and I want to print on or off
on the list. I assume that the proper place to do the transformation
is by using a cusomer adapter. Any examples on how to do that? Any
hints on the right method to override?  Thanks in advance.

  Best regards,

    Jorge
--~--~---------~--~----~------------~-------~--~----~

3. What the heck is a "task" ?

4. AudioRecordThread: buffer overflow... can it cause problems?

5. org.apache.http tutorial?

6. I get "unknown error" when opening simple TCP Socket

7. How to get the disk space using Android?