Android TabHost使用

本文介绍了一个使用 Android TabHost 创建多标签界面的例子。通过循环遍历布局资源并为每个标签分配特定的内容视图,实现了动态创建标签的功能。此方法有助于开发者快速搭建具备多个标签页的应用界面。
private TabHost tabHost;

private int[] layRes = { R.id.t_1, R.id.t_2 , R.id.t_3 };

@Override
protected void onCreate(Bundle instance)
{
super.onCreate(instance);

initResource();
}

/**
* 初始化资源
*
* @param
* @return void
* @throws
* @since TianTian
*/
private void initResource()
{
tabHost = super.getTabHost();
LayoutInflater.from(this).inflate(R.layout.thost, tabHost.getTabContentView(), true);
/*
* 循环取出所有布局标记
*/
for (int x = 0; x < this.layRes.length; x++)
{
TabSpec myTab = tabHost.newTabSpec("tab" + x); // 定义TabSpec
myTab.setIndicator("标签 - " + x); // 设置标签文字
myTab.setContent(this.layRes[x]); // 设置显示的组件
this.tabHost.addTab(myTab); // 增加标签
}
}

xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="@color/coral">

<LinearLayout android:id="@+id/linearLayout1"
android:layout_width="match_parent" android:layout_height="match_parent">

<LinearLayout android:layout_height="match_parent"
android:id="@+id/t_1" android:layout_width="wrap_content">

<ImageView android:layout_height="wrap_content"
android:src="@drawable/jt5" android:id="@+id/imageView1"
android:layout_width="wrap_content"></ImageView>

</LinearLayout>

<LinearLayout android:layout_height="match_parent"
android:id="@+id/t_2" android:layout_width="wrap_content">

<ImageView android:layout_height="wrap_content"
android:src="@drawable/jt6" android:id="@+id/imageView1"
android:layout_width="wrap_content"></ImageView>

</LinearLayout>

<LinearLayout android:layout_height="match_parent"
android:id="@+id/t_3" android:layout_width="wrap_content">

<ImageView android:layout_height="wrap_content"
android:src="@drawable/jt7" android:id="@+id/imageView1"
android:layout_width="wrap_content"></ImageView>

</LinearLayout>

</LinearLayout>

</LinearLayout>
打开链接下载源码: https://pan.quark.cn/s/a4b39357ea24 HFSS,其全称为High Frequency Structure Simulator,是由Ansys公司研发的一款高级三维电磁场仿真软件,主要应用于射频、微波以及光学领域内的设计工作与性能分析。当前压缩包内提供的是一个基于HFSS软件构建的偶极子天线模型,并且包含了该模型的仿真数据,我们将对这一模型及其关联的学术知识进行细致的探讨。偶极子天线属于天线设计中最基础的类型之一,其结构由两个大小相等且布局对称的导体单元构成,整体形状类似于汉字“工”。在2.4GHz的频率条件下,此类天线被广泛部署于Wi-Fi、蓝牙等无线通信系统的构建中。HFSS软件能够对偶极子天线的电气特性进行高精度模拟,涵盖辐射模式、增益水平、方向图形态、输入阻抗以及S参数等多个核心指标。 S参数(即Scattering Parameters),是用于评估天线或微波器件输入端与输出端之间相互影响程度的关键参数。S参数详细刻画了信号流经网络设备时的反射与传输状态,其中S11(输入反射系数)和S21(传输系数)是最为常用的两种表征方式。借助HFSS软件执行S参数仿真,可以获取天线在多种频率下的反射与传输特性表现,从而协助设计人员对天线的阻抗匹配程度和运行效率进行有效评估。在此模型中,S参数仿真工作业已完成,因此我们可以直接审视2.4GHz频率下的阻抗匹配状况,以验证天线在该工作频段内能否展现出理想的性能。 在"Project1_1.aedt"与"Project1.aedt"这两个提供的文件中,储存了HFSS项目的完整信息。这些文件内含了天线的几何构造细节、材料物理属性、边界约束条件、求解器配置参数以及仿真获取的结果...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值