TabHost使用(一)
来源:互联网 发布:谷歌语音识别python 编辑:程序博客网 时间:2024/04/28 18:32
第一步:创建布局文件
<?xml version="1.0" encoding="utf-8"?><TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp" /> </LinearLayout></TabHost>
第二步:创建三个Activity作为Tabhost内容
public class Activity1 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TextView textview = new TextView(this);
textview.setText("This is one tab");
setContentView(textview);
}
}
第三步:测试类
public class Activity1 extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView textview = new TextView(this); textview.setText("This is one tab"); setContentView(textview); }}
public class TabHostTestActivity extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TabHost tabHost=getTabHost();
tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("tab1").setContent(new Intent(TabHostTestActivity.this
,Activity1.class)));
tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("tab2").setContent(new Intent(TabHostTestActivity.this
,Activity2.class)));
tabHost.addTab(tabHost.newTabSpec("tab3").setIndicator("tab3").setContent(new Intent(TabHostTestActivity.this
,Activity3.class)));
tabHost.setCurrentTab(1);
}
}、
第四步:演示效果
- TabHost使用(一)
- TabHost使用心得(一)
- TabHost的使用(一)
- TabHost选项卡的实现(一):使用TabActivity实现
- TabHost使用(二)
- TabHost使用(三)
- TabHost实现(一)---------基本功能
- tabhost基本用法(一)
- tabhost的使用(1)
- Tabhost使用
- TabHost使用
- TabHost使用
- android 音乐播放器制作 之 Tabhost 简单使用(一)
- 菜鸟学Android之TabHost(一)
- 底部菜单栏(一) TabHost实现
- Andriod TabHost的使用TabHost
- tabhost 得使用和学习(2)
- tabhost,framelayout,tabwidget(一)
- Bitmap decode outof Memory
- hdu 4215 Number Theory?(打表)
- java.io.IOException: Server returned HTTP response code: 500 for URL
- ASP.NET 服务器控件渲染到客户端之后对应的HTML标签
- Uploading audio, video or image files from Android to php server.
- TabHost使用(一)
- 将注入进行到底--------远程线程实现 Dll 注入 汇编实现
- IRAF 安装 for Ubuntu 10.04
- js 的拖拉效果
- LookupPrivilegeValue
- 有关ucenter通讯失败的问题
- eclipse 的jetty配置jndi数据源
- 4大国外自由职业者项目外包网站
- 设置datetimepicket的时间为当天日期+当前时间,当天日期+“00:00:00”的格式,选择的日期+“23:59:59”的格式