I get it.
In the Xml file, I have to specify TabHost, as shown below:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mytabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
In the Java file:
public class HelloTest extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost = (TabHost) findViewById(R.id.mytabhost);
tabHost.setup();
source
share