系统自带的TabWidget

public class MainActivity extends TabActivity {
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		/*
		 * requestWindowFeature(Window.FEATURE_NO_TITLE);
		 * getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
		 * WindowManager.LayoutParams.FLAG_FULLSCREEN);
		 */

		TabHost tabhost = getTabHost();

		LayoutInflater.from(this).inflate(R.layout.main,tabhost.getTabContentView(), true);

		tabhost.addTab(tabhost.newTabSpec("all").setIndicator("所有通话记录1111").setContent(R.id.TextView01));
		tabhost.addTab(tabhost.newTabSpec("ok").setIndicator("已接来电111222333").setContent(R.id.TextView02));
		tabhost.addTab(tabhost.newTabSpec("cancel").setIndicator("未接来电2222222").setContent(R.id.TextView03));

		tabhost.setOnTabChangedListener(new OnTabChangeListener() {
			public void onTabChanged(String tabId) {
				Toast.makeText(MainActivity.this, tabId, 2000).show();
			}
		});

	}
}

 

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

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/FrameLayout01" 
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content">
	
	<TextView 
	android:id="@+id/TextView01" 
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" 
	android:text="所有通话记录"></TextView>
	
	<TextView 
	android:id="@+id/TextView02" 
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" 
	android:text="已接来电"></TextView>
	
	<TextView 
	android:id="@+id/TextView03" 
	android:layout_width="wrap_content" 
	android:layout_height="wrap_content" 
	android:text="未接来电"></TextView>
	
</FrameLayout>


 
系统自带的TabWidget

便签上的内容超过长度会滚动哦!!
 

你可能感兴趣的:(tabwidget)