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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T11:18:18+00:00 2026-05-28T11:18:18+00:00

Environment: Android 2.3.3 with Google API I know this is kind of long, but

  • 0

Environment: Android 2.3.3 with Google API

I know this is kind of long, but I posted all information in case you needed to refer to it. Thanks in advance!

I followed the Android example here: http://developer.android.com/guide/tutorials/views/hello-tabwidget.html, but I am getting the error “Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id”.

Here is the app flow:
The app begins at the home screen, and an Intent is created in onStart() and starts the CartActivity. Before the CartActivity is started, the app crashes with the RuntimeException “Could not create tab content because could not find view with id 2131034112”

CartActivity

import com.cart.R;

import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.util.Log;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TextView;

public class CartActivity extends TabActivity 
{
    private TextView cartNameLabel;
    private EditText inputCartName;

    private TextView priceLabel;
    private EditText inputPrice;

    private EditText inputFruit;
    private ListView displayFruits;

    private TabHost tabHost;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.cart);

        Log.i(this.getClass().toString(), "Before addTabs()");
        addTabs();
        Log.i(this.getClass().toString(), "After addTabs()");

        cartNameLabel = (TextView)findViewById(R.id.createCartNameLabel);

        inputCartName = (EditText)findViewById(R.id.enterCartName);

        priceLabel = (TextView)findViewById(R.id.createPriceLabel);

        inputPrice = (EditText)findViewById(R.id.enterPrice);

        inputFruit = (EditText)findViewById(R.id.enterFruit);    
    }

    /**
     * Adds and displays the tabs to the Activity
     */
    private void addTabs()
    {           
        tabHost = getTabHost();
        tabHost.addTab(tabHost.newTabSpec("Tab1+a").setIndicator("X").setContent(R.id.addTab1a));
        tabHost.addTab(tabHost.newTabSpec("Tab2").setIndicator("Y").setContent(R.id.addTab2));

        tabHost.setCurrentTab(0);
    }   

}

Cart.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:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:padding="5dp">

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

            <!-- Layout for Add 1 + a Tab -->
            <LinearLayout
                android:id="@+id/addTab1a"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">        
                <TextView
                android:id="@+id/createCartNameLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/createCartNameLabelText"/>

                <EditText 
                android:id="@+id/enterCartName"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>

                <TextView
                android:id="@+id/createPriceLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/priceLabelText"/>

                <EditText 
                android:id="@+id/enterPrice"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            </LinearLayout>

            <!-- Layout for Add Tab2 -->
            <LinearLayout
                android:id="@+id/addTab2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">        
                <TextView
                android:id="@+id/createFruitLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="@string/createFruitLabelText"/>

                <EditText 
                android:id="@+id/enterFruit"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            </LinearLayout>



    </LinearLayout>
</TabHost>

HomeActivity

package com.cart.activities;

import com.cart.R;
import com.cart.R.layout;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class HomeActivity extends Activity 
{
    private TextView welcomeMessage;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        welcomeMessage = (TextView)findViewById(R.id.welcomeMessage);           

    }

    @Override
    public void onStart()
    {
        super.onStart();

        Intent intent = new Intent(getApplicationContext(), CartActivity.class);
        HomeActivity.this.startActivity(intent);
    }    

}

main.xml

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

    <TextView
        android:id="@+id/welcomeMessage"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/welcome" />

</LinearLayout>

R.java

/* AUTO-GENERATED FILE.  DO NOT MODIFY.
 *
 * This class was automatically generated by the
 * aapt tool from the resource data it found.  It
 * should not be modified by hand.
 */

package com.cart;

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
    }
    public static final class id {
        public static final int addTab1a=0x7f050000;
        public static final int addTab2=0x7f050005;
        public static final int createCartNameLabel=0x7f050003;
        public static final int createFruitLabel=0x7f050006;
        public static final int createPriceLabel=0x7f050001;
        public static final int enterCartName=0x7f050007;
        public static final int enterFruit=0x7f050002;
        public static final int enterPrice=0x7f050004;                
        public static final int welcomeMessage=0x7f050008;
    }
    public static final class layout {
        public static final int cart=0x7f030000;
        public static final int main=0x7f030001;
    }
    public static final class string {
        public static final int app_name=0x7f040001;
        public static final int createCartNameLabelText=0x7f040002;
        public static final int createFruitLabelText=0x7f040004;        
        public static final int priceLabelText=0x7f040003;        
        public static final int welcome=0x7f040000;
    }
}

Cart Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cart"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="10" />
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.CAMERA"/>
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" 
        android:debuggable="true">

        <activity
            android:name=".activities.HomeActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name=".activities.CartActivity">
            <intent-filter></intent-filter>
        </activity>
    </application>

</manifest>
  • 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-28T11:18:19+00:00Added an answer on May 28, 2026 at 11:18 am

    Change the name of the Layout file to cart.xml

    When changed to the following format your sample runs

    <?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">
    
             <LinearLayout
                android:id="@+id/addTab1a"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">        
                <TextView
                android:id="@+id/createCartNameLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="CreateCartNameLabelText"/>
    
                <EditText 
                android:id="@+id/enterCartName"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
    
                <TextView
                android:id="@+id/createPriceLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="PriceLabelText"/>
    
                <EditText 
                android:id="@+id/enterPrice"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            </LinearLayout>
             <LinearLayout
                android:id="@+id/addTab2"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">        
                <TextView
                android:id="@+id/createFruitLabel"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:text="CreateFruitLabelText"/>
    
                <EditText 
                android:id="@+id/enterFruit"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"/>
            </LinearLayout>
        </FrameLayout>
    </LinearLayout>
    </TabHost>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating interactive charts in java for android environment. Google visualisation API is very
Under Android environment, I need to list all subclasses of one of my classes.
I know this question has been asked here before, but I don't think those
Is it possible to deploy an Android application to the google app engine environment?
Im getting this Error when loading an ESRI map inside the Android Environment. This
Possible Duplicate: Seemingly useless debugging environment for Android I've obviously been spoiled by Visual
I am rewriting the existing C++ application and adapting it for Android environment. In
I am new to the android programming and my working environment is eclipse helio
The Android virtual device (a simulated Android environment) doesn't run very smoothly on my
I'm driven crazy with this: Log.d(STATE, Environment.getExternalStorageState()); File f = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), work_data); Log.d(PATH,

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.