0
protected void onCreate(Bundle savedInstanceState) 
{
  super.onCreate(savedInstanceState);
  setContentView(R.layout.splash);

  TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);

  TabSpec homeTabSpec = tabHost.newTabSpec("tid1");
  TabSpec videoTabSpec = tabHost.newTabSpec("tid1");
  TabSpec aboutUsTabSpec = tabHost.newTabSpec("tid1");

  homeTabSpec.setIndicator("Home").setContent(new Intent(this,FirstActivity.class));
  homeTabSpec.setIndicator("tid1",getResources().getDrawable(R.drawable.home));

  videoTabSpec.setIndicator("Video").setContent(new Intent(this,VideoWeb.class));
  videoTabSpec.setIndicator("tid1",getResources().getDrawable(R.drawable.videos));

  aboutUsTabSpec.setIndicator("About Us").setContent(new     Intent(this,AboutWeb.class));
  aboutUsTabSpec.setIndicator("tid1",getResources().getDrawable(R.drawable.aboutus));

  tabHost.addTab(homeTabSpec);
  tabHost.addTab(videoTabSpec);
  tabHost.addTab(aboutUsTabSpec);
}

My xml--

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

<TabHost android:layout_width="fill_parent"

android:layout_height="fill_parent" 
xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@android:id/tabhost">

<LinearLayout android:id="@+id/LinearLayout01"

android:orientation="vertical" android:layout_height="fill_parent"

android:layout_width="fill_parent">

<TabWidget android:id="@android:id/tabs"

android:layout_height="wrap_content" android:layout_width="fill_parent"></TabWidget>

<FrameLayout android:id="@android:id/tabcontent"

android:layout_height="fill_parent" android:layout_width="fill_parent"></FrameLayout>

</LinearLayout>

</TabHost>
NickLH
  • 2,643
  • 17
  • 28
arpit
  • 555
  • 1
  • 7
  • 25
  • 1
    It appears that the error is within the launch of your `FirstClass` - can you post the code for that? – kaspermoerch Oct 31 '11 at 13:15
  • at com.example.vidushi.Home.onCreate(Home.java:44) means it is on line 44, have you debugged and stepped to this point to see the status of all variables? Something is null. – Jack Oct 31 '11 at 13:25
  • thanks for reply it is working.i want to show tabhost from bottom.can you tell me how?i show my xml. – arpit Oct 31 '11 at 13:28

1 Answers1

2

If you do not have a TabActivity defined in your xml layout, you should call tabHost.setup() adding anything to it.

So it should be:

TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
tabHost.setup()
Nicholas Magnussen
  • 769
  • 2
  • 9
  • 26