Android TabHost的学习笔记
来源:互联网 发布:windows xp sp3原版 编辑:程序博客网 时间:2024/05/17 23:30
- package cn.com.karl.music;
- import android.app.TabActivity;
- import android.content.Intent;
- import android.content.res.Resources;
- import android.os.Bundle;
- import android.view.Window;
- import android.view.WindowManager;
- import android.widget.TabHost;
- public class MainActivity extends TabActivity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
- WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setContentView(R.layout.main);
- Resources res = getResources();
- TabHost tabHost = getTabHost();
- TabHost.TabSpec spec;
- Intent intent;
- intent = new Intent().setClass(this, ListActivity.class);
- spec = tabHost.newTabSpec("music")
- .setIndicator("music", res.getDrawable(R.drawable.item))
- .setContent(intent);
- tabHost.addTab(spec);
- intent = new Intent().setClass(this, ArtistsActivity.class);
- spec = tabHost.newTabSpec("artist")
- .setIndicator("srtist", res.getDrawable(R.drawable.artist))
- .setContent(intent);
- tabHost.addTab(spec);
- intent = new Intent().setClass(this, AlbumsActivity.class);
- spec = tabHost.newTabSpec("special")
- .setIndicator("special", res.getDrawable(R.drawable.album))
- .setContent(intent);
- tabHost.addTab(spec);
- intent = new Intent().setClass(this, SongsActivity.class);
- spec = tabHost.newTabSpec("recent play")
- .setIndicator("recent play", res.getDrawable(R.drawable.album))
- .setContent(intent);
- tabHost.addTab(spec);
- tabHost.setCurrentTab(0);
- }
- }
页面布局:
- <?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:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical"
- 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>
阅读全文
0 0
- Android TabHost的学习笔记
- Android TabHost学习笔记
- android学习笔记31:TabHost
- Android学习笔记之TabHost
- android学习笔记----类似微信的TabHost
- Android学习笔记29:切换卡TabHost控件的使用
- Android学习笔记29:切换卡TabHost控件的使用
- [Android] 关于Fragment 和 TabHost的学习笔记
- TabHost的两种用法-Android学习笔记
- Android学习笔记二:TabHost控件的使用说明收集
- android学习笔记之四TabHost布局
- android学习笔记之四TabHost布局
- Android学习笔记-TabHost选项卡使用
- Android学习笔记-TabHost选项卡使用
- android学习笔记---fragment替代tabhost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Android学习笔记:TabHost 和 FragmentTabHost
- Unknown Treasure ————(hdu5446) 中国剩余定理+卢卡斯定理
- Android7 mediacodec SEI
- 一次解决问题的经过
- 封装自己的printf函数
- 获取项目中Classpath中的资源路径
- Android TabHost的学习笔记
- mybatis动态SQL标签的用法
- 学生信息管理系统(JAVA+SQl 2008 开发环境netbeans)之数据库链接
- rac安装常见问题
- 守护进程
- 时间序列分析之自相关函数图
- java语言基础-引出方法-方法定义-基本调用操作
- PWM控制电机
- 玩转break,return ,continue的使用和关系