从不同的layout添加tab也内容(tabcontent)<!--这里是layout.mian--><?xml version="1.0" encoding="utf-8"?><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent" android:layout_height="fill_parent"><!--tab1的布局 --><LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent"android:layout_height="fill_parent" androidrientation="vertical"><TextView android:text="result" android:id="@+id/result"android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView></LinearLayout><!--tab2的布局 --><LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent"android:layout_height="fill_parent" androidrientation="vertical"><AnalogClock android:id="@+id/widget36"android:layout_width="wrap_content" android:layout_height="wrap_content"></AnalogClock></LinearLayout><!--tab3的布局 --><LinearLayout android:id="@+id/tab3" android:layout_width="fill_parent"android:layout_height="fill_parent" androidrientation="vertical"><RadioGroup android:id="@+id/widget43"android:layout_width="166px" android:layout_height="98px"androidrientation="vertical"><RadioButton android:id="@+id/widget44"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="RadioButton"></RadioButton><RadioButton android:id="@+id/widget45"android:layout_width="wrap_content" android:layout_height="wrap_content"android:text="RadioButton"></RadioButton></RadioGroup></LinearLayout></FrameLayout><!--这里是layout.newgallery--><?xml version="1.0" encoding="utf-8"?><LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"        android:layout_width="fill_parent" android:layout_height="fill_parent"        androidrientation="vertical"  >      <TextView android:text="result33" android:id="@+id/result33"android:layout_width="fill_parent" android:layout_height="wrap_content"></TextView></LinearLayout><!--这里是Main.java-->package com.baotab;import android.app.TabActivity;import android.os.Bundle;import android.util.Log;import android.view.LayoutInflater;import android.view.View;import android.widget.TabHost;import android.widget.TabHost.TabContentFactory;public class Main extends TabActivity implements TabContentFactory {/** Called when the activity is first created. */private LayoutInflater inflater;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setTitle("Tab测试");TabHost tabHost = getTabHost();LayoutInflater.from(this).inflate(R.layout.main,  tabHost.getTabContentView(),  true);inflater = LayoutInflater.from(this);  //创建inflatertabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(R.id.tab1));tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab2").setContent(R.id.tab2));tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3").setContent(R.id.tab3));tabHost.addTab(tabHost.newTabSpec("tab44").setIndicator("tab42").setContent(this));}@Overridepublic View createTabContent(String paramString) {View view = null;view = inflater.inflate(R.layout.newgallery, null);Log.d("tabtest", "4");return view;};}

更多相关文章

  1. Android 之 四大组件、六大布局、五大存储
  2. Android横竖屏加载不同布局的适配方案
  3. Android布局LinearLayout+RelativeLayout知识点概括
  4. Android全屏时软键盘遮住输入框修改布局解决方案
  5. RelativeLayout相对布局方法总结
  6. Android测试框架或者工具对比

随机推荐

  1. 转 android launch flow
  2. phonegap底层原理学习和研究(一)
  3. android LinearLayout添加分隔线
  4. AsyncTask使用和源码解析
  5. android 反编译
  6. golang开发android应用(二) - go语言生成an
  7. Android分享新浪微博
  8. android 使用Intent传递数据之返回结果
  9. android菜鸟学习笔记16----Android项目打
  10. 调用Android中的软键盘