android选项卡
来源:互联网 发布:南宁广电网络 编辑:程序博客网 时间:2024/04/28 20:15
一个简单的选项卡:
1,首先有一个TabHost布局,必须包含TabHost,TabWidget,FrameLayout,新手注意id,
android:id="@android:id/tabs" android:id="@android:id/tabhost" android:id="@android:id/tabcontent"
2,onCreate()方法中获取Tabhost,初始化TabHost tabs = (TabHost) findViewById(R.id.tabhost);
tabs.setup();
3,tabs.newTabSpec("tag1")用来new一个tab,同时标记这个tab的tag
TabHost.TabSpec spec = tabs.newTabSpec("tag1");
4,setContent()用来处理点击这个tab后的动作,可以是这个Activity下的一个组件,如setContent(R.id.tab1),也可以是一个intent,比如:setContent(new Intent(this, SubTab.class))
spec.setContent(R.id.tab1);
spec.setIndicator("hahah");可以是setIndicator("hahah"),也可以包含其他的属性,如图片
可以简化:
LayoutInflater inflater = LayoutInflater.from(this);// 声明一个LayoutInflater对象
inflater.inflate(R.layout.tab1, tabHost.getTabContentView());
inflater.inflate(R.layout.tab2, tabHost.getTabContentView());
tabHost.addTab(tabHost.newTabSpec("tab01").setIndicator("哈哈哈哈")
.setContent(R.id.linerTab1));
tabHost.addTab(tabHost.newTabSpec("tab02").setIndicator("呵呵呵呵")
.setContent(R.id.FrameTab2));
5,最后添加tabs.addTab(spec)
- Android 选项卡使用
- Android 选项卡效果
- 【Android】选项卡使用
- android 自定义选项卡
- Android 选项卡实现
- android选项卡
- Android 选项卡 DEMO
- android 选项卡模型
- Android之选项卡
- android选项卡
- android 选项卡TabHost
- android 选项卡TabHost
- android 选项卡界面
- android选项卡
- android tab选项卡效果
- Android选项卡(TabWidget)例子
- android 选项卡(TabHost) 置底
- android之TabWidget选项卡
- 想法缘由
- 自定义GridView实现放大功能
- 2014年年终总结
- fetch = FetchType.EAGER
- VC开发类似Circos的图表
- android选项卡
- CodeBlocks问题解决
- iOS 自动化测试 积累
- Core Graphic(二):context详解
- MyBatis Batch Update Exception 使用foreach 批量update 出错
- android ListView显示多个类型item 和 item中控件抢夺焦点解决办法
- 何为三层架构
- uAP 吞吐率测试
- 算法提高 最大乘积