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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:11:45+00:00 2026-05-25T12:11:45+00:00

I have created a TabActivity and added TabWidget and frame to the layout. I

  • 0

I have created a TabActivity and added TabWidget and frame to the layout.

I have four other Activity classes with single label in each Activity. Four tabs are associated with four tabs.

When I am trying to launch the application in emulator, I am getting the below exception

09-03 23:24:43.905: ERROR/AndroidRuntime(450):
java.lang.NullPointerException 09-03 23:24:43.905:
ERROR/AndroidRuntime(450): at
android.widget.TabHost.dispatchWindowFocusChanged(TabHost.java:295)
09-03 23:24:43.905: ERROR/AndroidRuntime(450): at
android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)
09-03 23:24:43.905: ERROR/AndroidRuntime(450): at
android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:661)

public class TabHome extends TabActivity {

public void onCreate(Bundle savedInstanceState)
{

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    TabHost tabHost=getTabHost();
    TabHost.TabSpec tabSpec;
    Resources res=getResources();

    Intent intent;

    intent=new Intent().setClass(this, MyMap.class);        
    tabSpec=   tabHost.newTabSpec("Maps").setIndicator("Maps",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);       
    tabHost.addTab(tabSpec);

    intent=new Intent().setClass(this, MyStash.class);      
    tabSpec=  tabHost.newTabSpec("Stash").setIndicator("Stash",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);      
    tabHost.addTab(tabSpec);

    intent=new Intent().setClass(this, MyList.class);       
    tabSpec=  tabHost.newTabSpec("List").setIndicator("List",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);        
    tabHost.addTab(tabSpec);

    intent=new Intent().setClass(this, MySearch.class);     
    tabSpec=  tabHost.newTabSpec("Search").setIndicator("Search",res.getDrawable(R.drawable.ic_tab_artists)).setContent(intent);        
    tabHost.addTab(tabSpec);

    tabHost.setCurrentTab(2);


}
  • 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-25T12:11:46+00:00Added an answer on May 25, 2026 at 12:11 pm

    I have missed to mention the following attributes to main.xml

    android:id=”@android:id/tabhost” in TabHost tag

    and

    android:id=”@android:id/tabs” in TabWidget tag

    and

    android:id=”@android:id/tabcontent” in FrameLayout tag.

    Thanks all for your help!

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

Sidebar

Related Questions

I have created TabActivity class in which i am creating four tabs for my
I have created three tabs in TabActivity onCreate . How can I hide one
I have a TV Guide activity which extends TabActivity. The tabs are labelled (example)...
I have a TabActivity that has a TabHost with two tabs. Each tab has
Here is the scenario: I have an activity with 4 tabs, each tab with
I wish to have a single class which all of my Activity classes extend.
i have created a workflow activity that do give the item creater of a
I have created an abstract class which extends the Activity Class. I want to
I currently have this code that creates 4 tabs using tabactivity: public class toknapp
I have created a custom tabbar in my application (using TabHost and TabWidget ).

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.