我想让Android的标签栏看起来像Android。
这是我的代码:
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@android:id/tabhost"
android:orientation="vertical" >
<TabWidget
android:layout_width="fill_parent"
android:layout_height="40px"
android:id="@android:id/tabs"
android:layout_alignParentBottom="true"
></TabWidget>
</TabHost>
TabActivity.java
package com.saa;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;
public class TabActivity extends android.app.TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TabHost tabHost=getTabHost();
Intent intent = new Intent();
TabSpec tabSpec= tabHost.newTabSpec("one");
tabSpec.setIndicator("One", getResources().getDrawable(R.drawable.ic_launcher));
intent.setClass(this, tab1.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("two");
tabSpec.setIndicator("Two", getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab2.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("three");
tabSpec.setIndicator("Three", getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab3.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabSpec= tabHost.newTabSpec("four");
tabSpec.setIndicator("Four",getResources().getDrawable(R.drawable.ic_launcher));
intent = new Intent().setClass(this, tab4.class);
tabSpec.setContent(intent);
tabHost.addTab(tabSpec);
tabHost.setCurrentTab(0); // default tab
}
}
为了让Tabbar关闭,我需要做些哪些更改?我创建了其他类,如tab1.java,tab2.java等。