美文网首页
TabHost选项卡实例

TabHost选项卡实例

作者: Beck766 | 来源:发表于2017-04-18 14:55 被阅读0次

先看效果:

效果图

activity_tabhost.xml:

<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#0ef"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
    <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" />
    </LinearLayout>
</TabHost>

MainActivity.java:

public class IntentTabActivity extends TabActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tabhost);
        TabHost tabHost=getTabHost();
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("已接电话").setContent(new Intent(this,BeCalledActivity.class)));
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("呼出电话").setContent(new Intent(this,CalledActivity.class)));
        tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("未接电话").setContent(new Intent(this,NoCallActivity.class)));
    }
}

其他三个Activity就只是显示两个TextView,这里省略不写

相关文章

  • TabHost选项卡实例

    先看效果: activity_tabhost.xml: MainActivity.java: 其他三个Activi...

  • TabHost

    Android选项卡TabHost功能和用法

  • 九、Android选项卡TabHost功能和用法

    1、选项卡TabHost介绍TabHost可以方便地在窗口上放置多个标签页,每个标签页相当于获得了一个与外部容器大...

  • 选项卡(TabHost)使用

    目录 TabHost TabHost实现Tab切换, 实现类似通话记录界面的切换效果. 使用方式:从TabActi...

  • 使用ViewPager+Fragment实现选项卡切换效果

    实现效果 本实例主要实现用ViewPage和Fragment实现选项卡切换效果,选项卡个数为3个,点击选项卡或滑动...

  • 面向对象三

    面向对象中级 面向对象实例:选项卡 改写面向过程的选项卡image.png 改写面向对象程序的四要素 this 什...

  • 事件高级(二)

    事件高级(二) 可重用的选项卡实例 限制范围的拖拽实例 磁性吸附的拖拽实例 解决拖拽问题一:选中文字 事件捕获:s...

  • TabHost

    package com.example.text12_tabhost;import android.app.Act...

  • TabHost

    package com.example.test13_tabhost;import android.app.Act...

  • TabLayout+ViewPager实现选项卡切换效果

    原来项目中一直使用tabhost做切换效果,最近在整理代码,决定放弃tabhost,使用google自带的切换布局...

网友评论

      本文标题:TabHost选项卡实例

      本文链接:https://www.haomeiwen.com/subject/klnfzttx.html