anriod TabHost
package com.example.yanlei.mytk; import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import android.widget.Toast; import android.app.TabActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.widget.TabHost; public class MainActivity extends TabActivity { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("标签控件Tab");
TabHost tabHost = getTabHost();
LayoutInflater.from(this).inflate(R.layout.activity_main, tabHost.getTabContentView(), true);
tabHost.addTab(tabHost.newTabSpec("biaoqian1").setIndicator("标签tab1").setContent(R.id.tab1));
tabHost.addTab(tabHost.newTabSpec("biaoqian2").setIndicator("标签tab2").setContent(R.id.tab2));
tabHost.addTab(tabHost.newTabSpec("biaoqian3").setIndicator("标签tab3").setContent(R.id.tab3));
}
}
<?xml version="1.0" encoding="UTF-8"?> <FrameLayout android:layout_height="fill_parent" android:layout_width="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"> <TabHost
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/tabHost"
android:layout_gravity="left|center_vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"></TabWidget> <FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"> <LinearLayout
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"> <TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Text"
android:id="@+id/textView" />
</LinearLayout> <LinearLayout
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout> <LinearLayout
android:id="@+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"></LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</FrameLayout>
anriod TabHost的更多相关文章
- android 使用Tabhost 发生could not create tab content because could not find view with id 错误
使用Tabhost的时候经常报:could not create tab content because could not find view with id 错误. 总结一下发生错误的原因,一般的 ...
- Android 轮换页面+TabHost 实例
最终效果展示: 首先我们需要一个ViewPager控件,不过可以发现在左侧的控件列表中并没有这个控件 这时我们要去升级包中查看 然后在厘米找到 ViewPager.class 这时我们双击这个发现不能 ...
- tabhost 下 setOnItemClickListener失效的问题
分析了一下代码,应该是tabhost 的ontabchangedListener接管了下面应该由setOnItemClickListener接管的部分,导致不能相应setOnItemClickList ...
- 安卓初級教程(5):TabHost的思考
package com.myhost; import android.os.Bundle; import android.view.LayoutInflater; import android.wid ...
- Android 实现分页(使用TabWidget/TabHost)
注:本文为转载,但该内容本人已亲身尝试,确认该方法可行,代码有点小的改动,转载用作保存与分享. 原作者地址:http://gundumw100.iteye.com/blog/853967 个人吐嘈:据 ...
- 安卓TabHost页面
<?xml version="1.0" encoding="UTF-8"?> <!-- TabHost组件id值不可变--> <T ...
- Android TabHost使用
TabHost是Android中自带的选项卡控件,效果图如下: 主布局文件 <RelativeLayout xmlns:android="http://schemas.android. ...
- tabhost使用
Tabhost用法 使用方法一:使用同一个布局文件 在xml中如此定义tabhost: <RelativeLayout xmlns:android="http://schemas.an ...
- tab使用 TabActivity TabHost Tabspec常用方法
本文是参考Android官方提供的sample里面的ApiDemos的学习总结. TabActivity 首先Android里面有个名为TabActivity来给我们方便使用.其中有以下可以关 ...
随机推荐
- Python使用libsvm的“ImportError: No module named svmutil”问题
from:http://blog.csdn.net/xmu_jupiter/article/details/46830327 这几天快被Python的一些细节问题整死了,浪费了不少时间.现在把这些记录 ...
- andriod手机签到应用服务器设计
最近导师要求我和另一个同学开发一个手机上课签到应用,我负责客户端和服务器之间的通信架构编写和数据的存储 本人大学四年只用过汇编和C/C++,因此对andriod开发还是一窍不通,花了一个星期写出来了基 ...
- c++中继承和java中继承的对比
java中: class Parent{ public void test(int a){ System.out.println("Parent:" + a); System.ou ...
- [OpenCV] Face Detection
即将进入涉及大量数学知识的阶段,先读下“别人家”的博文放松一下. 读罢该文,基本能了解面部识别领域的整体状况. 后生可畏. 结尾的Google Facenet中的2亿数据集,仿佛隐约听到:“你们都玩儿 ...
- [Node.js] 使用File API 异步上传文件
原文地址:http://www.moye.me/2014/11/05/html5-filereader/ 最近在做一个网盘的项目,不出意外的涉及到大文件的上传,那么问题来了:如何实时的显示文件上传的进 ...
- 使用DirectWrite测量Direct2D文字大小
转载请注明出处:http://www.cnblogs.com/Ray1024 一.概述 最近在使用Direct2D和DirectWrite写引擎,在引擎中需要实现文本标签控件.但是文本标签的尺寸最好不 ...
- C++中指针和引用的区别
①指针可以为空,引用不能为空: ②指针可以被赋值,引用必须在声明时赋值,之后不能被赋值: ③指针可以指向堆中空间,引用不能指向堆中空间,如int &p=new int; 会编译出错.
- lnmp_auto:自动化安装lnmp环境脚本
朋友找我在一台机器上帮忙安装下discuz.想着搭建过好几次的lnmp了,但是还没有使用过"一键安装"的自动化脚本,去网上有搜索出来,但是运行的时候发现用root运行别人的脚本还是 ...
- IOS开发UI基础UITableView的属性
UITableView UITableView内置了两种样式:UITableViewStylePlain,UITableViewStyleGrouped <UITableViewDataSour ...
- IOS开发UI基础storyboard相关概念的认识
本文主要介绍一些基本的概念 为后面的学习做个准备 需要了解的知识点有以下几个方面: storyboard文件的认识 IBAction 和IBOutlet UIViewController控制器的认识 ...