Android选项卡TabHost功能和用法
1、布局文件
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/tabhost"
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.helloword.TabActivity" > <LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"/> <FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout> </LinearLayout> </TabHost>
tab1.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="左边 tab"/> </LinearLayout>
tab2.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="right tab"/> </LinearLayout>
2、Activity
package com.example.helloword; import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TabHost; public class TabActivity extends Activity implements View.OnClickListener{ @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_tab); TabHost tabHost = findViewById(android.R.id.tabhost);
tabHost.setup(); LayoutInflater inflater = LayoutInflater.from(this); inflater.inflate(R.layout.tab1, tabHost.getTabContentView());
inflater.inflate(R.layout.tab2, tabHost.getTabContentView()); tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("left").setContent(R.id.tab1)); tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("right").setContent(R.id.tab2)); } @Override
public void onPointerCaptureChanged(boolean hasCapture) {
// TODO Auto-generated method stub } @Override
public void onClick(View arg0) {
// TODO Auto-generated method stub } }
Android选项卡TabHost功能和用法的更多相关文章
- Android选项卡TabHost方式实现
1.布局XML: <?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android= ...
- android 选项卡TabHost
选项卡主要有TabHost.TabWiget和 FramentLayout3个组件组成,用于实现一个多标签的用户界面,通过他可以将一个复杂的对话分隔成若干个标签页,实现对信息的分类显示和管理.使用给组 ...
- Android ViewSwitcher 的功能与用法
ViewSwitcher 代表了视图切换组件, 本身继承了FrameLayout ,可以将多个View叠在一起 ,每次只显示一个组件.当程序控制从一个View切换到另个View时,ViewSwitch ...
- 选项卡(TabHost)的功能与用法
TabHost是一种非常实用的组件,TabHost可以很方便地在窗口上放置多个便签页,每个标签页相当于获得了一个与外部容器相同大小的组件摆法区域.通过这种方式,就可以在一个容器里放置更多组件,例如手机 ...
- Android 自学之画廊视图(Gallery)功能和用法
Gallery与之前讲的Spinner有共同的父类:AbsSpinner,表明Gallery和Spinner都是一个列表框.他们之间的区别在于Spinner显示的是一个垂直的列表框,而Gallery显 ...
- Android 自学之选项卡TabHost
选项卡(TabHost)是一种非常实用的组件,TabHost可以很方便地在窗口上放置多个标签页,每个标签页相当于获得了一个与外部容器相同大小的组建摆放区域.通过这种方式,就可以在一个容器中放置更多组件 ...
- android学习--TabHost选项卡组件
TabHost是一种非常有用的组件,TabHost能够非常方便地在窗体上放置多个标签页,每一个标签页获得了一个与外部容器同样大小的组件摆放区域.在手机系统的应用类似"未接电话".& ...
- Android零基础入门第63节:过时但仍值得学习的选项卡TabHost
原文:Android零基础入门第63节:过时但仍值得学习的选项卡TabHost 由于前几天参加一个学习培训活动,几乎每天都要从早晨7点到晚上一两点,没有什么时间来分享,实在抱歉中间断更了几天.从今天开 ...
- 浅谈Android选项卡(三)
上一节介绍了TabActivity的简单用法,但是现在的Api中已经不建议使用了,建议使用Fragment来替代以上的功能,下面介绍下使用Fragment和ViewPager的结合使用. http:/ ...
随机推荐
- Python适合练手的项目
原文地址:https://www.jianshu.com/p/039156321e30 项目地址:https://github.com/DeqianBai/Python-Project/tree/ma ...
- css 设置div半透明 悬浮在页面底部 不随滚动条滚动
.action-button { width: 100%; background:rgba(0,0,0,0.7); position:fixed; bottom:; left:; z-index:; ...
- Windows 10提示你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问
Windows 10提示你不能访问此共享文件夹,因为你组织的安全策略阻止未经身份验证的来宾访问 1.首先按window+R键打开运行.如下图 2.在运行中输入“gpedit.msc”来启动本地组策略编 ...
- npm link用法总结
npm link用来在本地项目和本地npm模块之间建立连接,可以在本地进行模块测试 具体用法: 1. 项目和模块在同一个目录下,可以使用相对路径 npm link ../module 2. 项目和模块 ...
- iOS - 使用SDWebImage缓存图片,MJPhotoBrowser展示图片的问题
需求:在项目中,使用WKWebView加载html的富文本,只点击图片的时候展示图片,其他的不显示 问题:第一次点击用SDWebImage,不加载网络图片,以后再点击可以正常显示图片,SDWebIma ...
- Docker容器部署Mysql数据库服务器
本节会用到的Docker命令如下: docker images 查看mysql镜像id docker run -d -p xxxxxxxxxxxxxxx/zhufc/mysql:v2 通过镜像生成 启 ...
- .NetCore中EFCore的使用整理(三)-关联表操作
一.查询关联表数据 StudyAboard_TestContext _context = new StudyAboard_TestContext(); CrmRole role = _context. ...
- linux_permission
linux命令与权限(permission denied):权限问题 a 上调权限 chmod 777 test.php b 更改为root su root 提示输入root密码 c root权 ...
- Docker 容器内无法通过 HTTP 访问外网
现象 内/外网 IP 和 域名 可以 ping 通 容器内无法访问宿主机所在内网及外网的 Web 服务(404) 通过 curl 查看返回头信息感觉是所有 Web 请求被中转到一个固定的 Nginx ...
- php imagick添加文字和图片的方法
Imagick添加文字和图片的方法<pre><?php $image = new Imagick(); $image->readImage("/home/www/wo ...