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 5844455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:17:40+00:00 2026-05-22T12:17:40+00:00

I am trying to implement TabLayout in an Activity, and I keep on getting

  • 0

I am trying to implement TabLayout in an Activity, and I keep on getting error for it.
My main_new.xml XML file is :

<?xml version="1.0" encoding="utf-8"?>
<TabHost
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" android:id="@+id/tabHost">

<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 android:id="@+id/tab1" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="50dp">
     <TextView android:layout_width="fill_parent" 
        android:layout_height="100px" 
        android:text="This is tab1"
        android:id="@+id/txt1"/>    

</LinearLayout>

<LinearLayout android:id="@+id/tab2" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingTop="50dp">
     <TextView android:layout_width="fill_parent" 
        android:layout_height="100px" 
        android:text="This is tab2"
        android:id="@+id/txt2"/>    

</LinearLayout>
</TabHost>

My Activity class is :

public class UltimateActivity extends Activity implements OnClickListener {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_new);
    TabHost tabHost = (TabHost)findViewById(R.id.tabHost);
    tabHost.setup();

    TabSpec spec1 = tabHost.newTabSpec("Tab 1");
    spec1.setContent(R.id.tab1); // Here iis where the errror points
    spec1.setIndicator("Tab 1");

    TabSpec spec2 = tabHost.newTabSpec("Info");
    spec2.setContent(R.id.tab2);
    spec2.setIndicator("Info");

    tabHost.addTab(spec1);
    tabHost.addTab(spec2);
}

}

Manifest file contains :

        <activity android:icon="@drawable/icon" android:label="Ultimate" android:name="UltimateActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

ERROR I get :

 05-18 22:13:56.072: ERROR/AndroidRuntime(634): Uncaught handler: thread main exiting due to uncaught exception
 05-18 22:13:56.083: ERROR/AndroidRuntime(634): java.lang.RuntimeException: Unable to start activity ComponentInfo{orange.android.vpn/orange.android.vpn.UltimateActivity}: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131296290
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.os.Handler.dispatchMessage(Handler.java:99)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.os.Looper.loop(Looper.java:123)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread.main(ActivityThread.java:4363)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at java.lang.reflect.Method.invokeNative(Native Method)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at java.lang.reflect.Method.invoke(Method.java:521)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at dalvik.system.NativeStart.main(Native Method)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634): Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131296290
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:587)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:578)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.widget.TabHost$TabSpec.setContent(TabHost.java:435)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at orange.android.vpn.UltimateActivity.onCreate(UltimateActivity.java:20)
 05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-18 22:13:56.083: ERROR/AndroidRuntime(634):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
05-18 22:13:56.083: ERROR/AndroidRuntime(634):     ... 11 more

I use SDK 1.6 and in my manist also have android:minSdkVersion=”4″ . I have used http://www.codeproject.com/KB/android/AndroidTabs.aspx for Tab tutorial.

Can anyone help me know the error. I have spend hours in this error. Any help is highly appreciated. Please try to help soon.

Thanks

  • 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-22T12:17:41+00:00Added an answer on May 22, 2026 at 12:17 pm

    My 1 mistake in xml file :
    I had closed Framelayout insteead of closing it after full layout.
    That was my mistake. I found it and the problem is solved.

    Thanks a lot to everyone for viewing it.
    @yogsma, Thanks for taking efforts to help me out.

    Thanks

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am trying to implement a generic way for reading sections from a config file.
I'm trying implement Data Annotation to my Linq to SQL objects. The .dbml file
I am trying to implement this function which works everywhere except every IE version
Trying to implement the new FP 10.1 Global error handler into my projects but
Im trying to implement a graphedit filter file i created. I am using 3ivx
Im trying to implement an activity that uses ExpandableListView and I have gotten so
All I am currently trying implement something along the lines of dim l_stuff as
trying to implement a dialog-box style behaviour using a separate div section with all
I am trying to implement string unescaping with Python regex and backreferences, and it
I'm trying to implement a data compression idea I've had, and since I'm imagining

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.