`
hemowolf
  • 浏览: 151933 次
  • 性别: Icon_minigender_1
  • 来自: 广州
社区版块
存档分类
最新评论

android学习笔记之四TabHost布局

阅读更多

1,继承自TabActivity类

2,getTabHost()获取TabHost实例

3, LayoutInflater.from(this).inflate(界面布局Id, tabHost.getTabContentView(), true);

4,添加选项卡
    tabHost.addTab(
        tabHost.newTabSpec(选项卡Tag)   //返回TabSpec实例
 .setIndicator(选项卡显示标题) //或.setIndicator(CharSequence label, Drawable icon)
 .setContent(选项卡绑定视图Id)); //或.setContent(Intent intent) 设置其他Activity为选项卡

5,监听选项卡更改事件
    TabHost.setOnTabChangedListener 重写public void onTabChanged(String arg0)//arg0=选项卡Tag

6,方法
 setCurrentTab (int index)//设置第几个选项卡选中
 setCurrentTabByTag (String tag)////设置选项卡选中,tag=选项卡Tag
      相对应的方法
 getCurrentTab ()
 getCurrentTabByTag ()

7,注意事项
    Toast在这种布局中不起作用

分享到:
评论
1 楼 flyjava 2010-07-31  
        

相关推荐

Global site tag (gtag.js) - Google Analytics