ITeye博客

android 入门demo Tab选项卡

chengyu2099 · 2012-03-24 20:39 · Android · 移动开发 · Markdown

[code="java"]package com.isoftstone.cry; import android.app.TabActivity; import android.os.Bundle; import android.view.LayoutInflater; import android.widget.TabHost; public class TabActivityTest extends TabActivity { private TabHost tabHost ; @Override protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); tabHost = getTabHost(); //LayoutInflater是用来找layout下xml布局文件,并且实例化 LayoutInflater layoutInflater = (LayoutInflater)this.getSystemService(LAYOUT_INFLATER_SERVICE); layoutInflater.inflate(R.layout.framelayout,tabHost.getTabContentView(),true); // LayoutInflater.from(this).inflate(R.layout.framelayout,tabHost.getTabContentView(),true); tabHost.addTab(tabHost.newTabSpec("all").setIndicator("所有通话记录") .setContent(R.id.tabHosttextView1)); tabHost.addTab(tabHost.newTabSpec("ok").setIndicator("已接来电") .setContent(R.id.tabHosttextView2)); tabHost.addTab(tabHost.newTabSpec("canncel") .setIndicator("未接来电").setContent(R.id.tabHosttextView3)); // 不引用xml tabhost,可自定义设置视图 // setContentView(tabHost); } } [/code][code="xml"] [/code]

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。