Android入门第十一篇之TabHost,TabWidget

本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处!

       这回要介绍的是Android的Tab控件,Tab控件可以达到分页的效果,让一个屏幕的内容尽量丰富,当然也会增加开发的复杂程度,在有必要的时候再使用。Android的Tab控件使用起来有点奇怪,必须包含和按照以下的顺序:

TabHost控件->TabWidget(必须命名为tabs)->FrameLayout(必须命名为tabcontent)。

 

接下来贴出本例运行的截图:

 

main.xml的源码:

 

[xhtml]  view plain copy print ?
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <TabHost android:layout_width="fill_parent"  
  3.     android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/TabHost1">  
  4.     <TabWidget android:id="@android:id/tabs"  
  5.         android:layout_height="wrap_content" android:layout_width="fill_parent">  
  6. </TabWidget>  
  7.     <FrameLayout android:id="@android:id/tabcontent"  
  8.         android:paddingTop="65px" android:layout_width="fill_parent" android:layout_height="fill_parent">  
  9.         <LinearLayout android:layout_height="wrap_content" android:id="@+id/Tab1" android:orientation="vertical" android:layout_width="fill_parent">  
  10.            <EditText android:layout_height="wrap_content" android:id="@+id/edtTab1" android:layout_width="fill_parent"></EditText>  
  11.            <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnTab1" android:text="Tab1"></Button>  
  12.         </LinearLayout>  
  13.         <LinearLayout android:layout_height="wrap_content" android:id="@+id/Tab2" android:layout_width="fill_parent" android:orientation="horizontal">  
  14.            <EditText android:layout_height="wrap_content" android:id="@+id/edtTab2" android:layout_width="wrap_content" android:layout_weight="300"></EditText>  
  15.            <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnTab2" android:text="Tab2"></Button></LinearLayout>  
  16.     </FrameLayout>  
  17. </TabHost>  

 

程序源码:

[java]  view plain copy print ?
  1. package com.testTab;  
  2. import android.app.TabActivity;  
  3. import android.os.Bundle;  
  4. import android.view.View;  
  5. import android.widget.Button;  
  6. import android.widget.EditText;  
  7. import android.widget.TabHost;  
  8. import android.widget.TabHost.TabSpec;  
  9. public class testTab extends TabActivity {//基于TabActivity构建  
  10.       
  11.     Button btnTab1,btnTab2;  
  12.     EditText edtTab1,edtTab2;  
  13.     /** Called when the activity is first created. */  
  14.     @Override  
  15.     public void onCreate(Bundle savedInstanceState) {  
  16.         super.onCreate(savedInstanceState);  
  17.         setContentView(R.layout.main);  
  18.           
  19.         TabHost tabs = getTabHost();  
  20.         //设置Tab1  
  21.         TabSpec tab1 = tabs.newTabSpec("tab1");  
  22.         tab1.setIndicator("tab1");      // 设置tab1的名称  
  23.         tab1.setContent(R.id.Tab1);    // 关联控件  
  24.         tabs.addTab(tab1);                // 添加tab1  
  25.           
  26.         btnTab1=(Button)this.findViewById(R.id.btnTab1);  
  27.         edtTab1=(EditText)this.findViewById(R.id.edtTab1);  
  28.         btnTab1.setOnClickListener(new ClickEvent());  
  29.           
  30.         //设置Tab2  
  31.         TabSpec tab2 = tabs.newTabSpec("tab2");  
  32.         tab2.setIndicator("tab2");        
  33.         tab2.setContent(R.id.Tab2);      
  34.         tabs.addTab(tab2);                  
  35.           
  36.         btnTab2=(Button)this.findViewById(R.id.btnTab2);  
  37.         edtTab2=(EditText)this.findViewById(R.id.edtTab2);  
  38.         btnTab2.setOnClickListener(new ClickEvent());  
  39.           
  40.         tabs.setCurrentTab(0);  
  41.     }  
  42.       
  43.     class ClickEvent implements View.OnClickListener {  
  44.         @Override  
  45.         public void onClick(View v) {  
  46.             if(v==btnTab1)  
  47.             {  
  48.                 edtTab1.setText("tab1");  
  49.             }  
  50.             else if(v==btnTab2)  
  51.             {  
  52.                 edtTab2.setText("tab2");  
  53.             }  
  54.         }  
  55.       
  56.     }  
  57. }  

【源码免费下载链接】:https://renmaiwang.cn/s/p79ex 作为一种广泛应用的光子学设备,调Q光纤激光器通过调节激光系统的Q因子,我们可以有效地产生高强度、短时宽的光脉冲。在现代科学技术中,MATLAB作为一款功能强大的数值计算和仿真软件,在科学与工程领域中,它通常被用来进行数值模拟和数据分析。对于像调Q光纤激光器这样的复杂系统,我们可以通过下载名为“基于matlab的调Q光纤激光器模拟Q.zip”的压缩包来获取相关的建模代码或教学资源。这种技术的核心机制是通过动态调整谐振腔中的能量损耗比(即增益与损耗之和的比例),从而实现瞬间释放大量能量,形成高功率脉冲。在MATLAB环境下进行这样的仿真研究,通常会围绕以下几个重点内容展开:首先,我们需要深入理解激光器的工作原理,这包括对其物理组成及功能的基本认识。其次,在涉及到光纤作为主要载波介质时,也需要掌握其特定的光学特性。此外,在数值模拟过程中,我们还必须建立合理的数学模型来描述激光腔内的光场演化过程等关键环节。通过这些分析可以发现,调Q光纤激光器的工作原理与优化设计在很大程度上依赖于对激光器内部物理机制的深入理解以及精准的数值模拟技术的应用。在此基础上,我们需要掌握如何通过调节系统的各个参数(如Q开关的动作速度、泵浦功率等),来实现最佳的工作性能。同时,在实际操作中,我们还需要注意一些关键的技术要点,例如如何处理光纤中的非线性效应对激光器输出的影响。最后,在完成数值模拟之后,我们可以通过MATLAB提供的强大可视化工具,将仿真结果以图形或曲线的形式呈现出来,从而更直观地分析系统的动态行为特性。综上所述,“基于matlab的调Q光纤激光器模拟Q.zip”这个压缩包可能包含了完整的代码实现和相关实验数据,这对于我们深入学习这一技术领域具有重要的参考价值。如果有机会可以运行这些文件并进行进一步研究,相信会对掌握
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值