Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 614407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:06:31+00:00 2026-05-13T18:06:31+00:00

I am having an issue with using TabHost in a new Intent of type

  • 0

I am having an issue with using TabHost in a new Intent of type TabActivity which I hope you can point me in the right direction. Funnily it works fine when I try to view it in the original Intent : setContentView(R.layout.main)

I get a “forced closed” and within logcat, I get the following error even though my Tabhost id = “@android:id/tabhost”:

02-18 22:23:11.937:
ERROR/AndroidRuntime(5944): Caused by:
java.lang.RuntimeException: Your
content must have a TabHost whose id
attribute is ‘android.R.id.tabhost’

I have declared the second intent in the Manifest.xml file:
XML:

<activity android:name=".NextActivity" android:label="@string/app_name" > 

Within the first activity (MainActivity), I start the second intent (NextActivity), with extras, as follows:

Intent nextActivity = new Intent(MainActivity.this,NextActivity.class); 
Bundle b_next=new Bundle(); 

b_next.putString("s_string", myString); 

nextActivity.putExtras(b_next); 

In my NextActivity.java file, I get the extras and try to display the TabHost View:

public class NextActivity extends TabActivity { 
     @Override 
     public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState); 

        String myString; 
        Bundle b_initial; 

        b_initial = getIntent().getExtras(); 

        myString = b_initial.getString("s_string"); 

     setContentView(R.layout.main); 

        } 
}

I get the same error with using the TabHost example on the Android Developer site (Hellow View):

Main.xml:

<?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="fill_parent"> 
    <LinearLayout 
        android:orientation="vertical" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"> 
        <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"> 
            <TextView 
                android:id="@+id/textview1" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" 
                android:text="this is a tab" /> 
            <TextView 
                android:id="@+id/textview2" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" 
                android:text="this is another tab" /> 
            <TextView 
                android:id="@+id/textview3" 
                android:layout_width="fill_parent" 
                android:layout_height="fill_parent" 
                android:text="this is a third tab" /> 
        </FrameLayout> 
    </LinearLayout> 
</TabHost>

Thanks in advance folks…

CLARIFICATION:
This is what I really get from LogCat:

java.lang.NullPointerException
at android.widget.TabHost.dispatchWindowFocusChanged(TabHost.java 285)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java 640)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java 640)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java 640)
at android.view.ViewRoot.handleMessage(ViewRoot.java 1645)
at android.os.Handler.dispatchMessage(Handler.java 99)
at android.os.Looper.loop(Looper.java 123)
at android.app.ActivityThread.main(ActivityThread.java 3948)
at java.lang.reflect.Method.invokeNative(Native
Method)
at java.lang.reflect.Method.invoke(Method.java 521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java 782)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java 540)
at dalvik.system.NativeStart.main(Native
Method)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:06:32+00:00Added an answer on May 13, 2026 at 6:06 pm

    I have previously constructed tabhosts with an id of android:id="@+id/tabhost". Does this work for you?

    You could also consider constructing your tab view programmatically:

        TabHost t = getTabHost();
        TabSpec tab = t.newTabSpec(label)
                       .setIndicator(label, icon)
                       .setContent(intent);
        t.addTab(tab);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

having an issue using a NSMutableArray; In my implementation file applicationDidFinishLaunching method I have
I am having a issue using Google's SDC (Secure Data Connector) with my Google
I'm having an issue using the Cookie class of the Servlet API 2.5 on
I am having an issue using the Moq library to mock an Enum within
I’m having an issue using SqlBulkCopy when nullable columns are involved. It sounds like
I'm having an issue using a MatrixCursor to populate my ListView : private void
I am having an issue using the maxrows property of tilelist. My code looks
I'm having an issue using jQuery autocomplete with dynamically created inputs (again created with
I have found an interesting application on the net and i am using it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.