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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:16:21+00:00 2026-06-10T05:16:21+00:00

I have a Tab Host with two Tabs: One for an image gallery and

  • 0

I have a Tab Host with two Tabs: One for an image gallery and another to open a page. Independently the TabHost works fine but when I want to access it through a previous activity the app crashes. can anyone please tell me what the problem is? Whether I have to add something or what I am doing is wrong. Please do tell me if there is another method. My code is given below:

public class DelhimapActivity extends TabActivity{

   TabHost tab;
   Intent intent;
   GridView grid;

   public void onCreate(Bundle savedInstanceState){
      super.onCreate(savedInstanceState);
      setContentView(R.layout.delhimap);
      tab = getTabHost();

      tab.addTab(tab.newTabSpec("tab1").setIndicator("Images").setContent(R.id.gridView1));
      tab.addTab(tab.newTabSpec("tab2").setIndicator("About").setContent(intent));
      grid = (GridView) findViewById(R.id.gridView1);
      grid.setAdapter(new ImageAdapter(this));
      intent.setClass(this, DelhiLay.class);
      startActivity(intent);

      tab.setCurrentTab(0);
   }

}

My ImageAdapter:

public class ImageAdapter extends BaseAdapter {
   private Context mContext;

   public ImageAdapter(Context c) {
      // TODO Auto-generated constructor stub
      mContext= c;
   }

   public int getCount() {
      // TODO Auto-generated method stub
      return mThumbIds.length;
   }

   public Object getItem(int position) {
      // TODO Auto-generated method stub
      return null;
   }

   public long getItemId(int position) {
      // TODO Auto-generated method stub
      return 0;
   }

   public View getView(int position, View convertView, ViewGroup parent) {
      // TODO Auto-generated method stub
      ImageView imageView;
      if (convertView == null) {  // if it's not recycled, initialize some attributes
         imageView = new ImageView(mContext);            

         imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
         imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
         imageView.setPadding(8, 8, 8, 8);

         //myButton.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));

      } else {
         imageView = (ImageView) convertView;
      }

      imageView.setImageResource(mThumbIds[position]);
      return imageView;
   }

  // references to our images
  private Integer[] mThumbIds = {
        R.drawable.ben, R.drawable.brent,
        R.drawable.cean,
        R.drawable.charters,
        R.drawable.lynn,
        R.drawable.mark,
        R.drawable.paul,
        R.drawable.philip
  };
} 

And accessing it from another activity like this:

public void onEnter(View v){

      prg = ProgressDialog.show(this, "", "Loading...");
      new Handler().postDelayed(new Runnable() {

            public void run() {
      Intent inta = new Intent(NewActivity.this,DelhimapActivity.class);
      NewActivity.this.startActivity(inta);
      NewActivity.this.finish();
            }
      },3000
      );
}

This is the XML which has the TabHost:

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


<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"

            android:tabStripEnabled="true">
        </TabWidget>

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

            <GridView
                android:id="@+id/gridView1"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:numColumns="3" >
            </GridView>
            <LinearLayout 
                android:id="@+id/linear"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

            </LinearLayout>

        </FrameLayout>

    </LinearLayout>

This is my LogCat for this Activity:

08-23 13:56:46.008: E/AndroidRuntime(365): FATAL EXCEPTION: main
**08-23 13:56:46.008: E/AndroidRuntime(365): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.delhicious.suryastra/com.delhicious.suryastra.DelhimapActivity}: java.lang.RuntimeException: Your content must have a TabHost whose id attribute is 'android.R.id.tabhost'**
  • 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-10T05:16:22+00:00Added an answer on June 10, 2026 at 5:16 am

    Replace @+id/tabhost with @android:id/tabhost in your layout file.

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

Sidebar

Related Questions

I have a tabhost with two tabs. Each tab has his own activity. My
I have one activity in which I am having one TabHost with two tabs.
I need to have a TabHost consisting of two tabs where each tab represented
I have a TabActivity that has a TabHost with two tabs. Each tab has
I'm trying to create a tablayout where have two tabs for now. One tab
I am making a activity using Tab-Host. I have two tabs. When I start
I am using tab host(tabs) in application, it have four tabs on home screen,
Hi i have two tabs in my tab widget,i want to apply the two
In my project I am using a tab host. In one of the tabs
I have a tabhost with some tabs, and each tab have implemented the method

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.