Is there any way to add tab layout without letting the activity to extend TabActivity?
I want to add tabs to the l开发者_运维百科ayout of my activity, but I don't want the activity to extend TabActivity. The example in http://developer.android.com/resources/tutorials/views/hello-tabwidget.html only gave example of subclass of TabActivity.
Is there any way I can make it without extending TabActivity?
Thanks.
I figured it out.
In Xml file I should define TabHost like 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 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();
精彩评论