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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:54:24+00:00 2026-05-19T15:54:24+00:00

I’ve created a TabHost example with 1 tab which is running fine. I’m adding

  • 0

I’ve created a TabHost example with 1 tab which is running fine. I’m adding views in tabs with TabContentFactory using TabSpec.setContent(TabHost.TabContentFactory contentFactory)

But as soon as I try to add tabs by views in tabs using View/Resource IDs using TabSpec.setContent(int viewId) my app crashes. The code is as follows:

public class MainAct extends TabActivity implements TabContentFactory{
    protected Resources res;
    protected ListView listView;
    protected LayoutInflater inflater;

    @Override
    public void onCreate(Bundle savedInstanceState) {
    /*init*/
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        res = getResources();
        listView = new ListView(this);

    /*prepare tabs*/
        TabHost tabHost = getTabHost();
        TabSpec spec;

        spec = tabHost.newTabSpec(res.getString(R.string.label_project));
        spec.setIndicator(res.getString(R.string.label_project));
        spec.setContent(this); // << this works perfect
        //spec.setContent(R.id.list_item); // << CRASHES
        //spec.setContent(R.id.list_item2); // << CRASHES
        tabHost.addTab(spec);
    }

    @Override
    public View createTabContent(String tag) {
        return listView;
    }
}

My XML files are as follows

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp"
    android:textSize="22sp"
    android:id="@+id/list_item">
</TextView>

and

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/list_item2"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:id="@+id/TextView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="list_item2">
    </TextView>
</LinearLayout>

Both of them defines IDs properly, yet they crash. I’ve already gone through following online tutorials:

http://android-pro.blogspot.com/2010/08/tabbed-applications-in-android.html

http://www.codeproject.com/KB/android/AndroidTabs.aspx

http://www.androidpeople.com/android-custom-listview-tutorial-example/

All of them describes how to add views in tabs using IDs, but none works for me.

All I want to do is to define a view in a layout file and add it inside my tab using IDs. Please help.

EDIT LogCat:

01-29 21:53:44.665: DEBUG/AndroidRuntime(1336): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
01-29 21:53:44.675: DEBUG/AndroidRuntime(1336): CheckJNI is ON
01-29 21:53:44.945: DEBUG/AndroidRuntime(1336): --- registering native functions ---
01-29 21:53:45.395: DEBUG/ddm-heap(1336): Got feature list request
01-29 21:53:45.934: DEBUG/PackageParser(63): Scanning package: /data/app/vmdl69673.tmp
01-29 21:53:45.944: INFO/PackageParser(63): org.pixeroid.gtd: compat added android.permission.WRITE_EXTERNAL_STORAGE android.permission.READ_PHONE_STATE
01-29 21:53:46.164: DEBUG/dalvikvm(63): GC freed 8169 objects / 609984 bytes in 156ms
01-29 21:53:46.285: INFO/PackageManager(63): Removing non-system package:org.pixeroid.gtd
01-29 21:53:46.285: DEBUG/PackageManager(63): Removing package org.pixeroid.gtd
01-29 21:53:46.295: DEBUG/PackageManager(63):   Activities: org.pixeroid.gtd.MainAct
01-29 21:53:46.414: DEBUG/PackageManager(63): Scanning package org.pixeroid.gtd
01-29 21:53:46.414: INFO/PackageManager(63): /data/app/vmdl69673.tmp changed; unpacking
01-29 21:53:46.426: DEBUG/installd(31): DexInv: --- BEGIN '/data/app/vmdl69673.tmp' ---
01-29 21:53:46.735: DEBUG/dalvikvm(1342): DexOpt: load 53ms, verify 85ms, opt 3ms
01-29 21:53:46.745: DEBUG/installd(31): DexInv: --- END '/data/app/vmdl69673.tmp' (success) ---
01-29 21:53:46.755: DEBUG/PackageManager(63):   Activities: org.pixeroid.gtd.MainAct
01-29 21:53:46.764: DEBUG/ActivityManager(63): Uninstalling process org.pixeroid.gtd
01-29 21:53:46.774: DEBUG/ActivityManager(63): Force removing process ProcessRecord{43f230b8 1327:org.pixeroid.gtd/10029} (org.pixeroid.gtd/10029)
01-29 21:53:46.774: INFO/Process(63): Sending signal. PID: 1327 SIG: 9
01-29 21:53:46.805: DEBUG/ActivityManager(63): Received spurious death notification for thread android.os.BinderProxy@43d66520
01-29 21:53:46.925: INFO/installd(31): move /data/dalvik-cache/data@app@vmdl69673.tmp@classes.dex -> /data/dalvik-cache/data@app@org.pixeroid.gtd.apk@classes.dex
01-29 21:53:46.934: DEBUG/PackageManager(63): New package installed in /data/app/org.pixeroid.gtd.apk
01-29 21:53:47.085: DEBUG/AndroidRuntime(1336): Shutting down VM
01-29 21:53:47.095: DEBUG/dalvikvm(1336): DestroyJavaVM waiting for non-daemon threads to exit
01-29 21:53:47.105: DEBUG/dalvikvm(1336): DestroyJavaVM shutting VM down
01-29 21:53:47.105: DEBUG/dalvikvm(1336): HeapWorker thread shutting down
01-29 21:53:47.115: DEBUG/dalvikvm(1336): HeapWorker thread has shut down
01-29 21:53:47.125: DEBUG/jdwp(1336): JDWP shutting down net...
01-29 21:53:47.125: INFO/dalvikvm(1336): Debugger has detached; object registry had 1 entries
01-29 21:53:47.125: DEBUG/dalvikvm(1336): VM cleaning up
01-29 21:53:47.176: ERROR/AndroidRuntime(1336): ERROR: thread attach failed
01-29 21:53:47.195: DEBUG/ActivityManager(63): Uninstalling process org.pixeroid.gtd
01-29 21:53:47.215: DEBUG/dalvikvm(1336): LinearAlloc 0x0 used 623916 of 5242880 (11%)
01-29 21:53:47.474: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f0700e5
01-29 21:53:47.504: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f020031
01-29 21:53:47.504: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f020030
01-29 21:53:47.504: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f050000
01-29 21:53:47.535: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f060000
01-29 21:53:47.584: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f060001
01-29 21:53:47.785: DEBUG/dalvikvm(141): GC freed 294 objects / 13368 bytes in 327ms
01-29 21:53:48.155: DEBUG/dalvikvm(63): GC freed 4525 objects / 319208 bytes in 399ms
01-29 21:53:48.485: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f0700e5
01-29 21:53:48.514: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f020031
01-29 21:53:48.514: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f020030
01-29 21:53:48.514: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f050000
01-29 21:53:48.565: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f060000
01-29 21:53:48.595: WARN/ResourceType(63): Resources don't contain package for resource number 0x7f060001
01-29 21:53:48.895: DEBUG/AndroidRuntime(1347): >>>>>>>>>>>>>> AndroidRuntime START <<<<<<<<<<<<<<
01-29 21:53:48.977: DEBUG/AndroidRuntime(1347): CheckJNI is ON
01-29 21:53:49.504: DEBUG/AndroidRuntime(1347): --- registering native functions ---
01-29 21:53:49.905: DEBUG/ddm-heap(1347): Got feature list request
01-29 21:53:50.425: INFO/ActivityManager(63): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=org.pixeroid.gtd/.MainAct }
01-29 21:53:50.505: INFO/ActivityManager(63): Start proc org.pixeroid.gtd for activity org.pixeroid.gtd/.MainAct: pid=1353 uid=10029 gids={1015}
01-29 21:53:50.514: DEBUG/AndroidRuntime(1347): Shutting down VM
01-29 21:53:50.524: DEBUG/dalvikvm(1347): DestroyJavaVM waiting for non-daemon threads to exit
01-29 21:53:50.534: DEBUG/dalvikvm(1347): DestroyJavaVM shutting VM down
01-29 21:53:50.534: DEBUG/dalvikvm(1347): HeapWorker thread shutting down
01-29 21:53:50.544: DEBUG/dalvikvm(1347): HeapWorker thread has shut down
01-29 21:53:50.544: DEBUG/jdwp(1347): JDWP shutting down net...
01-29 21:53:50.544: INFO/dalvikvm(1347): Debugger has detached; object registry had 1 entries
01-29 21:53:50.555: DEBUG/dalvikvm(1347): VM cleaning up
01-29 21:53:50.585: ERROR/AndroidRuntime(1347): ERROR: thread attach failed
01-29 21:53:50.645: DEBUG/dalvikvm(1347): LinearAlloc 0x0 used 639500 of 5242880 (12%)
01-29 21:53:50.864: DEBUG/ddm-heap(1353): Got feature list request
01-29 21:53:51.494: DEBUG/AndroidRuntime(1353): Shutting down VM
01-29 21:53:51.494: WARN/dalvikvm(1353): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-29 21:53:51.504: ERROR/AndroidRuntime(1353): Uncaught handler: thread main exiting due to uncaught exception
01-29 21:53:51.535: ERROR/AndroidRuntime(1353): java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pixeroid.gtd/org.pixeroid.gtd.MainAct}: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131099648
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.os.Looper.loop(Looper.java:123)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread.main(ActivityThread.java:4363)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at java.lang.reflect.Method.invokeNative(Native Method)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at java.lang.reflect.Method.invoke(Method.java:521)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at dalvik.system.NativeStart.main(Native Method)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353): Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131099648
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:587)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:578)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.widget.TabHost$TabSpec.setContent(TabHost.java:435)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at org.pixeroid.gtd.MainAct.onCreate(MainAct.java:45)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-29 21:53:51.535: ERROR/AndroidRuntime(1353):     ... 11 more
01-29 21:53:51.554: INFO/Process(63): Sending signal. PID: 1353 SIG: 3
01-29 21:53:51.554: INFO/dalvikvm(1353): threadid=7: reacting to signal 3
01-29 21:53:51.554: ERROR/dalvikvm(1353): Unable to open stack trace file '/data/anr/traces.txt': Permission denied
01-29 21:53:55.305: INFO/Process(1353): Sending signal. PID: 1353 SIG: 9
01-29 21:53:55.334: INFO/ActivityManager(63): Process org.pixeroid.gtd (pid 1353) has died.
01-29 21:53:55.365: INFO/UsageStats(63): Unexpected resume of com.android.launcher while already resumed in org.pixeroid.gtd
01-29 21:53:55.494: WARN/InputManagerService(63): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@43c98060
  • 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-19T15:54:25+00:00Added an answer on May 19, 2026 at 3:54 pm

    All I want to do is to define a view in a layout file and add it inside my tab using IDs.

    If you look at your XML files in your question, you will notice that you have no TabHost, no TabWidget, and no FrameLayout. I will assume that these are in some third XML file that you declined to include in your question.

    Adding by ID only works for existing children of the FrameLayout, such as in this sample project.

    What you may want to do is use the <include> element inside your FrameLayout to load these other files in, or simply copy their contents into the FrameLayout and eliminate the separate files.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
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
Basically, what I'm trying to create is a page of div tags, each has
In order to apply a triggered animation to all ToolTip s in my app,
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and

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.