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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:57:44+00:00 2026-06-02T05:57:44+00:00

I am trying to create a tab view with will switch to a different

  • 0

I am trying to create a tab view with will switch to a different content view by Id. Here is my tab activity:

public class TabViews extends TabActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabviews);
    TabHost tabHost = getTabHost();

    LayoutInflater.from(this).inflate(R.layout.tabviews, tabHost.getTabContentView(), true);

    tabHost.addTab(tabHost.newTabSpec("apples")
            .setIndicator("Apples")
            .setContent(R.id.apples));
    tabHost.addTab(tabHost.newTabSpec("events")
            .setIndicator("Events")
            .setContent(R.id.events));
    tabHost.addTab(tabHost.newTabSpec("attend")
            .setIndicator("Attending")
            .setContent(R.id.attend));
}
}

Here is the tabviews xml layout.

<?xml version="1.0" encoding="utf-8"?>

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<TextView android:id="@+id/view1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="test"/>   

<TextView android:id="@+id/view2"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="test"/>

<TextView android:id="@+id/view3"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:text="test"/>

</FrameLayout>

I have three other xml layouts attend, events and apples which i can access by creating a new intent the calling startActivity on that Intent.

Here is my R.java class:

public final class R {
public static final class attr {
}
public static final class drawable {
    public static final int bdgdefault=0x7f020000;
    public static final int logo=0x7f020001;
    public static final int black_0=0x7f020002;
    public static final int black_1=0x7f020003;
    public static final int black_2=0x7f020004;
    public static final int black_3=0x7f020005;
    public static final int black_4=0x7f020006;
    public static final int blue_0=0x7f020007;
    public static final int blue_1=0x7f020008;
    public static final int blue_2=0x7f020009;
    public static final int blue_3=0x7f02000a;
    public static final int blue_4=0x7f02000b;
    public static final int brown_0=0x7f02000c;
    public static final int brown_1=0x7f02000d;
    public static final int brown_2=0x7f02000e;
    public static final int brown_3=0x7f02000f;
    public static final int brown_4=0x7f020010;
    public static final int btn_black=0x7f020011;
    public static final int btn_black_1=0x7f020012;
    public static final int btn_black_off=0x7f020013;
    public static final int btn_dropdown_down=0x7f020014;
    public static final int btn_dropdown_left_only=0x7f020015;
    public static final int btn_dropdown_left_right_collapsed=0x7f020016;
    public static final int btn_dropdown_neither=0x7f020017;
    public static final int btn_dropdown_neither_up_down=0x7f020018;
    public static final int btn_dropdown_right_only=0x7f020019;
    public static final int btn_dropdown_up=0x7f02001a;
    public static final int btn_dropdown_up_down=0x7f02001b;
    public static final int btn_white=0x7f02001c;
    public static final int button=0x7f02001d;
    public static final int grac=0x7f02001e;
    public static final int ic_launcher=0x7f02001f;
    public static final int ic_menu_jitsu=0x7f020020;
    public static final int ic_menu_jiu=0x7f020021;
    public static final int ic_menu_name=0x7f020022;
    public static final int mainlogo=0x7f020023;
    public static final int purple_0=0x7f020024;
    public static final int purple_1=0x7f020025;
    public static final int purple_2=0x7f020026;
    public static final int purple_3=0x7f020027;
    public static final int purple_4=0x7f020028;
    public static final int red_0=0x7f020029;
    public static final int red_1=0x7f02002a;
    public static final int mylogo=0x7f02002b;
    public static final int spinner_press=0x7f02002c;
    public static final int spinner_select=0x7f02002d;
    public static final int white_0=0x7f02002e;
    public static final int white_1=0x7f02002f;
    public static final int white_2=0x7f020030;
    public static final int white_3=0x7f020031;
    public static final int white_4=0x7f020032;
}
public static final class id {
    public static final int amattendees=0x7f060006;
    public static final int attend=0x7f060013;
    public static final int attendam=0x7f060000;
    public static final int attendboth=0x7f060002;
    public static final int attendpm=0x7f060001;
    public static final int back=0x7f06000f;
    public static final int bdg=0x7f06000b;
    public static final int bdgBackground=0x7f060009;
    public static final int btn_login=0x7f06001b;
    public static final int btn_newuser=0x7f06001c;
    public static final int description=0x7f060011;
    public static final int details=0x7f06000c;
    public static final int emailaddress=0x7f060019;
    public static final int events=0x7f06000e;
    public static final int grouplogo=0x7f060012;
    public static final int mainlogo=0x7f060018;
    public static final int nearestvenue=0x7f060016;
    public static final int notattending=0x7f060003;
    public static final int password=0x7f06001a;
    public static final int playbutton=0x7f060014;
    public static final int pmattendees=0x7f060007;
    public static final int progressBar=0x7f06000d;
    public static final int qrdecode=0x7f060015;
    public static final int rewarddate=0x7f060010;
    public static final int textView1=0x7f060017;
    public static final int title=0x7f060008;
    public static final int tv_am=0x7f060004;
    public static final int tv_pm=0x7f060005;
    public static final int view1=0x7f06001d;
    public static final int view2=0x7f06001e;
    public static final int view3=0x7f06001f;
    public static final int wv_qr=0x7f06000a;
}
public static final class layout {
    public static final int attend=0x7f030000;
    public static final int apples=0x7f030001;
    public static final int events=0x7f030002;
    public static final int list_items_attendees=0x7f030003;
    public static final int main=0x7f030004;
    public static final int tabviews=0x7f030005;
}
public static final class string {
    public static final int AM=0x7f040009;
    public static final int Login=0x7f040002;
    public static final int Update=0x7f04000a;
    public static final int am=0x7f04000d;
    public static final int amattendees=0x7f040011;
    public static final int app_name=0x7f040001;
    public static final int attend_both=0x7f04000f;
    public static final int attend_pm=0x7f04000e;
    public static final int back=0x7f040005;
    public static final int badge_details=0x7f040006;
    public static final int email_text=0x7f040007;
    public static final int empty=0x7f04000c;
    public static final int events=0x7f040004;
    public static final int hello=0x7f040000;
    public static final int new_user=0x7f040003;
    public static final int not_attending=0x7f040010;
    public static final int password_text=0x7f040008;
    public static final int pmattendees=0x7f040012;
    public static final int qrdecode=0x7f04000b;
}
public static final class style {
    public static final int ButtonText=0x7f050000;
}
}

Here is the error I am receiving:

04-17 10:14:48.608: E/AndroidRuntime(11307):java.lang.RuntimeException: Unable to start activity ComponentInfo{org.jujitsu.app.com/org.jujitsu.app.com.TabViews}:java.lang.RuntimeException: Could not create tab content because could not find view with id 2131099659

more:

04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1816)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1837)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread.access$1500(ActivityThread.java:132) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1033)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.os.Handler.dispatchMessage(Handler.java:99) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.os.Looper.loop(Looper.java:143)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread.main(ActivityThread.java:4196) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at java.lang.reflect.Method.invokeNative(Native Method) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at java.lang.reflect.Method.invoke(Method.java:507) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at dalvik.system.NativeStart.main(Native Method) 
04-17 10:14:48.608: E/AndroidRuntime(11307): Caused by: java.lang.RuntimeException: Could not create tab content because could not find view with id 2131099659
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:595)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.widget.TabHost$ViewIdContentStrategy.<init>(TabHost.java:586)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.widget.TabHost$TabSpec.setContent(TabHost.java:441) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at org.jujitsu.app.com.TabViews.onCreate(TabViews.java:26) 
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
04-17 10:14:48.608: E/AndroidRuntime(11307):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1780)
04-17 10:14:48.608: E/AndroidRuntime(11307):    ... 11 more

Not sure what I am doing wrong. I am a bit new to this.

UPDATE: Ok so.. What I mean is.. I want to change the Activity using tabs. Heres is how I did it. The answer was to set the content by Intent instead using tabHost.addTab(tabHost.newTabSpec(“tab2”) .setIndicator(“Something”) .setContent(new Intent(this, myActivity.class)));

Thankyou all those who helped. It made me consider more options.

Cheers, Joe.

  • 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-02T05:57:46+00:00Added an answer on June 2, 2026 at 5:57 am

    Your xml should have something like ,

      <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"
              >
    
        <FrameLayout  
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <TextView android:id="@+id/view1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="test"/>   
    
        <TextView android:id="@+id/view2"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="test"/>
    
        <TextView android:id="@+id/view3"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="test"/>
    
        </FrameLayout>
        </TabHost>
    

    examples:
    http://www.androidhive.info/2011/08/android-tab-layout-tutorial/
    http://www.codeproject.com/Articles/107693/Tabbed-Applications-in-Android

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

Sidebar

Related Questions

I am trying to create a tab-like interface where I will switch views by
I am trying to implement Tab View for my activity. I am getting an
I am trying to create a jQuery content slider that will stop when a
I'm trying to create a nice generic way of setting the tab index on
Ok so I am trying create a login script, here I am using PHP5
I followed the example in the Android website to create a tab activity with
i am trying to create a custom tab in my android app and i
I'm trying to create a custom tableviewcell within a view. Specifically, I want to
I am trying to create template/BaseActivity class for other developers to use, as a
I'm trying to add a split view inside of a tab bar, and since

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.