`

系统自带的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>


 

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

  • 大小: 18.3 KB
分享到:
评论

相关推荐

    android 切换卡(TabWidget)

    TabWidget的核心功能在于TabHost,它是Android系统提供的一个容器,用于管理TabWidget和一个内容视图。TabHost通过TabSpec对象来配置每个标签页,每个TabSpec包含一个指示器(通常是文字或图标)和一个内容。 在`...

    qt做一个带有日历和钟表的界面

    首先,我们要关注的核心是"qt自带的日历控件"。Qt库中的QCalendarWidget是一个方便的组件,它允许用户选择日期并显示在一个标准的日历视图中。我们可以直接在代码中添加QCalendarWidget到布局中,设置其属性如字体、...

    QT简单功能网页浏览器

    这通常是通过WebView组件的内置WebEngine或QWebChannel来实现的,它们可以解析HTML5的`&lt;video&gt;`和`&lt;audio&gt;`标签,并调用系统自带的媒体播放器或者利用QT自身的多媒体模块进行播放。 在实现这个浏览器的过程中,...

    二种tab布局

    在“二种tab布局”这个主题中,我们将深入探讨两种主要的Tab实现方式:一是使用Android自带的`TabHost`和`TabWidget`组件,二是使用现在更流行的`ViewPager`配合`TabLayout`。 1. **`TabHost`和`TabWidget`的使用**...

    Android例子源码tabhost+activity+slidingMenu

    **SlidingMenu**:SlidingMenu是一种侧滑菜单控件,常用于实现类似原生Android系统抽屉效果,让用户从屏幕边缘滑动以展示隐藏的菜单。相比于Android自带的NavigationView,SlidingMenu提供更多的自定义选项和更好的...

Global site tag (gtag.js) - Google Analytics