1

I'm working on my first Android project, and I'm trying to set a particular intent into a tab and i'm facing some severe issues.

Below is my code which creates each tab:

private void setupTab(final View view, final String tag, int imageId) {
    View tabview = createTabView(mTabHost.getContext(), tag, imageId);

    Intent intent = new Intent(this, MyNewActivity.class);
    TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(intent);

    mTabHost.addTab(setContent);
}

I keep seeing the following stacktrace after the above function runs:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.myapp/com.myapp.tabs.CustomTabActivity}: java.lang.IllegalStateException: Did you forget to call 'public void setup(LocalActivityManager activityGroup)'?
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)

However, I read the following sites:

TabActivity that create an intent onClick button but the tabhost of activity reciver disappear

Adding an intent to a TabActivity in Android

and it seems from the above that my code is correct? Is there something i'm missing?

EDIT

Made some progress...

Previously my TabHost as extending Activity but now I am extending TabActivity and it's going through...however my Intent is failing on the onCreate function on the line setContentView(R.layout.mylayout);

with the error:

addView(View, LayoutParams) is not supported in AdapterView

I read the following for that:

http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html

It's using the same method?

Community
  • 1
  • 1
KVISH
  • 12,923
  • 17
  • 86
  • 162

1 Answers1

2

Using the link above (http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html), I was able to get this implemented.

KVISH
  • 12,923
  • 17
  • 86
  • 162