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

  • SEARCH
  • Home
  • 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 7771915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:45:50+00:00 2026-06-01T16:45:50+00:00

I’ve followed the Android tutorial for TabLayout , and I’m now trying to modify

  • 0

I’ve followed the Android tutorial for TabLayout, and I’m now trying to modify it by using a layout as well as an activity per tab. Unfortunately, when adding a TabSpec to my TabHost, my app is crashing with a “Resource ID Not valid” error.

I believe the error here is related to Dalvik not understanding my reference to my tab layout XML file, but don’t understand why this is the case. I have tried using additional <include> statements in my main.xml file, to no avail. Any help would be very welcome!

The crashing Java code:

public class TabLayoutActivity extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Resources res = getResources();
    //mTabHost = getTabHost();
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();

    TabHost.TabSpec spec; 
    Intent intent;

    //Search tab
    intent = new Intent(this, SearchActivity.class);
    spec = mTabHost.newTabSpec("search_tab");
    spec.setIndicator("Search", res.getDrawable(R.drawable.magnifyingglass));
    spec.setContent(intent);        
    mTabHost.addTab(spec); //this line crashes


    //Allergies tab - when the above tab is commented out, this tab adds successfully
    intent = new Intent(this, AllergiesActivity.class);
    spec = mTabHost.newTabSpec("allergies_tab")
            .setIndicator("Allergies", res.getDrawable(R.drawable.man))
            .setContent(intent);

    mTabHost.addTab(spec);

    mTabHost.setCurrentTab(0);
}
}

The offending tab’s Activity:

public class SearchActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.id.search_tab_layout);
}
}

The other (working) tab’s activity (notice a layout is not specified):

public class AllergiesActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    TextView textView = new TextView(this);
    textView.setText("Allergies");
    setContentView(textView);

}
}

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"
    android:orientation="vertical">

    <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">

        </TabWidget>

        <FrameLayout android:id="@android:id/tabcontent"
                     android:layout_width="fill_parent"
                     android:layout_height="fill_parent">


        </FrameLayout>
    </LinearLayout>

</TabHost>

search_tab.xml – is this not being included somehow?

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


</LinearLayout>

log output:

04-09 16:08:23.434: D/ddm-heap(532): Got feature list request
04-09 16:08:23.843: D/AndroidRuntime(532): Shutting down VM
04-09 16:08:23.843: W/dalvikvm(532): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
04-09 16:08:23.843: E/AndroidRuntime(532): Uncaught handler: thread main exiting due to uncaught exception
04-09 16:08:23.873: E/AndroidRuntime(532): java.lang.RuntimeException: Unable to start activity ComponentInfo{mattjackson.allergyassassin/mattjackson.allergyassassin.TabLayoutActivity}: java.lang.RuntimeException: Unable to start activity ComponentInfo{mattjackson.allergyassassin/mattjackson.allergyassassin.SearchActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f050003 type #0x12 is not valid
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.os.Looper.loop(Looper.java:123)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.main(ActivityThread.java:4363)
04-09 16:08:23.873: E/AndroidRuntime(532):  at java.lang.reflect.Method.invokeNative(Native Method)
04-09 16:08:23.873: E/AndroidRuntime(532):  at java.lang.reflect.Method.invoke(Method.java:521)
04-09 16:08:23.873: E/AndroidRuntime(532):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-09 16:08:23.873: E/AndroidRuntime(532):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-09 16:08:23.873: E/AndroidRuntime(532):  at dalvik.system.NativeStart.main(Native Method)
04-09 16:08:23.873: E/AndroidRuntime(532): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{mattjackson.allergyassassin/mattjackson.allergyassassin.SearchActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f050003 type #0x12 is not valid
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.startActivityNow(ActivityThread.java:2335)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:648)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.widget.TabHost.setCurrentTab(TabHost.java:320)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.widget.TabHost.addTab(TabHost.java:213)
04-09 16:08:23.873: E/AndroidRuntime(532):  at mattjackson.allergyassassin.TabLayoutActivity.onCreate(TabLayoutActivity.java:31)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-09 16:08:23.873: E/AndroidRuntime(532):  ... 11 more
04-09 16:08:23.873: E/AndroidRuntime(532): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f050003 type #0x12 is not valid
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.content.res.Resources.loadXmlResourceParser(Resources.java:1870)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.content.res.Resources.getLayout(Resources.java:730)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.view.LayoutInflater.inflate(LayoutInflater.java:318)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-09 16:08:23.873: E/AndroidRuntime(532):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.Activity.setContentView(Activity.java:1622)
04-09 16:08:23.873: E/AndroidRuntime(532):  at mattjackson.allergyassassin.SearchActivity.onCreate(SearchActivity.java:11)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-09 16:08:23.873: E/AndroidRuntime(532):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-09 16:08:23.873: E/AndroidRuntime(532):  ... 20 more
04-09 16:08:23.903: I/dalvikvm(532): threadid=7: reacting to signal 3
04-09 16:08:23.903: E/dalvikvm(532): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
  • 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-06-01T16:45:51+00:00Added an answer on June 1, 2026 at 4:45 pm

    In your SearchActivity you have to set the layout. You try to set a view( from your layout) as your layout of the activity. Instead of

     setContentView(R.id.search_tab_layout);
    

    do

     setContentView(R.layout.search_tab);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to render a haml file in a javascript response like so:

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.