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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:47:56+00:00 2026-06-04T12:47:56+00:00

I am using following code to add tabs on a tabHost but crashes on

  • 0

I am using following code to add tabs on a tabHost but crashes on first to last line, spec.setContent(intent). Debugger says not too much. Thank you.

from Registrat,

Intent intentIOS = new Intent(Registrat.this, TabBar_Activity.class);
Bundle bundle = new Bundle();
bundle.putString("idusuari", idusuari);
String appid = null;

from TabBar_Activity,

private void setTabs(String numTabs){

        addTab(tab1name, "tab1", myTab1.class);
        addTab(tab2name, "tab2", myTab2.class);
}

private void addTab(String labelId, String imageName, Class<?> c)
    {
      TabHost tabHost = getTabHost();
          Intent intent = new Intent(this, c);
          TabHost.TabSpec spec = tabHost.newTabSpec("tab" + labelId); 

          View tabIndicator = LayoutInflater.from(this).inflate(R.layout.tab_indicator, getTabWidget(), false);
          TextView title = (TextView) tabIndicator.findViewById(R.id.title);
          title.setText(labelId);    

          spec.setIndicator(tabIndicator);
          spec.setContent(intent);
          tabHost.addTab(spec);
    }

05-25 11:18:49.725: E/AndroidRuntime(428): FATAL EXCEPTION: main
05-25 11:18:49.725: E/AndroidRuntime(428): java.lang.IllegalStateException: Could not execute method of the activity
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.view.View$1.onClick(View.java:2072)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.view.View.performClick(View.java:2408)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.view.View$PerformClick.run(View.java:8816)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.os.Handler.handleCallback(Handler.java:587)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.os.Handler.dispatchMessage(Handler.java:92)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.os.Looper.loop(Looper.java:123)
05-25 11:18:49.725: E/AndroidRuntime(428):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-25 11:18:49.725: E/AndroidRuntime(428):  at java.lang.reflect.Method.invokeNative(Native Method)
05-25 11:18:49.725: E/AndroidRuntime(428):  at java.lang.reflect.Method.invoke(Method.java:521)
05-25 11:18:49.725: E/AndroidRuntime(428):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

and follows…

  • 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-04T12:47:57+00:00Added an answer on June 4, 2026 at 12:47 pm

    To set a tab, I am using following the code and it works fine.

    TabHost tabHost = getTabHost();
    
    // Tab for Photos
    TabSpec photospec = tabHost.newTabSpec("Photos");
    // setting Title and Icon for the Tab
    photospec.setIndicator("Photos", getResources().getDrawable(R.drawable.icon_photos_tab));
    Intent photosIntent = new Intent(this, PhotosActivity.class);
    photospec.setContent(photosIntent);
    
    // Tab for Songs
    TabSpec songspec = tabHost.newTabSpec("Songs");
    songspec.setIndicator("Songs", getResources().getDrawable(R.drawable.icon_songs_tab));
    Intent songsIntent = new Intent(this, SongsActivity.class);
    songspec.setContent(songsIntent);
     // Adding all TabSpec to TabHost
    tabHost.addTab(photospec); // Adding photos tab
    tabHost.addTab(songspec); // Adding songs tab
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using following code for add button with image on tool bar, but
I'm using jQuery ui tabs with the following code but am having trouble adding
I am using the following code to add multiple TextViews to CommonsWare ViewSwiper but
I am using the following code to add a contact, but I get the
I'm using following code to add rounded corners to my UIImage, but the problem
I am using the following code to add the next line in the same
I'm using the following code to add separators between my menu items: #navigation_center li:before
I have added a UIScrollVIew using IB. Then using the following code i add
I'm using the following code, using the SharpZipLib library, to add files to a
I add many check boxes to the excel sheet programaticaly using the following code:

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.