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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:33:18+00:00 2026-06-14T14:33:18+00:00

I have two fragments inside my activity. That works fine. Now inside one of

  • 0

I have two fragments inside my activity. That works fine. Now inside one of my fragment, I need two tabbed contents. And in each tab, I need to inflate a view. How can I do that inside the oncreateview method? is it possible?

Here is my XML layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="match_parent"
android:background="@drawable/texture_background"
android:baselineAligned="false"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="60dp"
    android:background="#000" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="60dp"
        android:layout_marginBottom="10dp"
        android:padding="10dp"
        android:text="header"
        android:textColor="#fff"
        android:textSize="25dp" >
    </TextView>
</LinearLayout>
<TabHost
    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" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:visibility="gone" />

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

Here is my oncreateview method inside the fragment.

 public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
  View view = inflater.inflate(R.layout.saved_deals_fragment, container,false);
  TabHost tabs=(TabHost)view.findViewById(android.R.id.tabhost);
  tabs.setup();
  TabHost.TabSpec tab = tabs.newTabSpec("my tab content");
  tab.setIndicator("my tab content");
  tabs.addTab(tab);
  return view;
}

Here is my error:

    11-19 21:29:32.666: E/AndroidRuntime(28686): FATAL EXCEPTION: main
11-19 21:29:32.666: E/AndroidRuntime(28686): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example/com.example.WrapperActivity}:   java.lang.IllegalArgumentException: you must specify a way to create the tab content
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.os.Looper.loop(Looper.java:137)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread.main(ActivityThread.java:5039)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at java.lang.reflect.Method.invokeNative(Native Method)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at java.lang.reflect.Method.invoke(Method.java:511)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at dalvik.system.NativeStart.main(Native Method)
11-19 21:29:32.666: E/AndroidRuntime(28686): Caused by: java.lang.IllegalArgumentException: you must specify a way to create the tab content
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.widget.TabHost.addTab(TabHost.java:225)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at com.example.fragments.SavedFragment.onCreateView(SavedDealsFragment.java:120)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.Fragment.performCreateView(Fragment.java:1695)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1057)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.BackStackRecord.run(BackStackRecord.java:682)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1435)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.Activity.performStart(Activity.java:5113)
11-19 21:29:32.666: E/AndroidRuntime(28686):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2153)

do I need to provide any other details?

  • 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-14T14:33:19+00:00Added an answer on June 14, 2026 at 2:33 pm

    You don’t provide the content for your tabs. You could use a TabContentFactory to build a content like this:

    TabHost.TabSpec tab = tabs.newTabSpec("tab1");
    tab.setIndicator("my tab content");
    tab.setContent(new TabHost.TabContentFactory() {
    
                @Override
                public View createTabContent(String tag) {
                    if (tag.equals("tab1")) {
                        // create/inflate the view for the tab 1
                        return view;
                    } else {
                        // the same as tab 1 for the other tabs if you have any             
                }
            });
    tabs.addTab(tab);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need your help. I have one Activity with two fragments: one fragment with
I have two fragments in an activity where one fragment takes up 70% and
I have created one application in that I need two fragment, So i declared
I have a ViewPager with 3 fragments into it. Everything works fine with two
So I have an Activity which has a FragmentPagerAdapter and inside each fragment I
I have two fragments in an Activity, In portrait mode the first one (ListFragment)
I have a layout with two Fragments in it. Second one loads dynamically. Fragment
I have an activity with two fragments . I am not using <fragment/> tags,
Have two actionsheet buttons and one modalviewcontroller on mainviewcontroller in application. Now for two
I have two fragments: 1st fragment consists of a large button in the middle

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.