Tab标签的使用【安卓入门六】
来源:互联网 发布:九游软件下载 编辑:程序博客网 时间:2024/04/28 07:22
=======================================================================
1、在主activity中添加一个Button按钮,利用按钮跳转到Tab标签中
private Button tabViewButton = null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); tabViewButton = (Button)findViewById(R.id.tabViewButton); tabViewButton.setOnClickListener(new tabViewButtonListener()); } //利用intent对象转到tab标签的activity中 class tabViewButtonListener implements OnClickListener{ public void onClick(View arg0) { // TODO Auto-generated method stub Intent intent = new Intent(); intent.setClass(TabViewTest.this, TabViewDemo.class); TabViewTest.this.startActivity(intent); } }
2、建立Tab的布局文件,tab_value.xml
<FrameLayout xmlns:android="http://schemas.android.com/ apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="这个是第一个Tab标签" /> <TextView android:id="@+id/view2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="这个是第二个Tab标签" /> <TextView android:id="@+id/view3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="这个是第三个Tab标签" /></FrameLayout>
3、建立Tab的activity,
protected void onCreate(Bundle savedInstanceState) { // TODO Auto-generated method stub super.onCreate(savedInstanceState); setTitle("TabViewDemo"); TabHost tabHost = getTabHost(); LayoutInflater.from(this).inflate(R.layout.tab_demo, tabHost.getTabContentView(),true); tabHost.addTab(tabHost.newTabSpec("Tab1").setIndicator("Tab1"). setContent(R.id.view1)); tabHost.addTab(tabHost.newTabSpec("Tab2")setIndicator("Tab2"). setContent(R.id.view2)); tabHost.addTab(tabHost.newTabSpec("Tab3").setIndicator("Tab3"). setContent(R.id.view3)); }
4、在AdroidManifest.xml中注册Tab的activity。
<activity android:name=".TabViewDemo" android:label="@string/app_view"> </activity>
- Tab标签的使用【安卓入门六】
- 安卓开发中Tab标签页的使用——TabHo…
- jquery tab标签的使用
- 安卓Andriod使用入门(六)【动态GridView控件】
- 经典效果组件篇4:安卓的tab标签控件
- 仿CSDN安卓客户端(一)-----viewpaper和ViewPageIndicator实现CSDN客户端Tab标签的功能
- MFC入门学习之控件(3)标签控件Tab Control的添加和使用
- Android中仿tab标签的使用
- Android Tab标签的使用基础
- android Tab标签的使用基础
- Android Tab标签的使用基础
- Android Tab标签的使用基础
- 标签Tab切换 PagerSlidingTabStrip的使用
- VC 标签TAB使用
- 使用标签控件Tab
- 安卓开发使用的六种图表开发包
- javascript的tab标签
- vc++的tab标签
- 今天
- 使用javascript解析xml实现省市县三级联动
- .NET命名规范
- java中数组的常用操作
- fedora 13下使用代理(wget)
- Tab标签的使用【安卓入门六】
- AVD启动问题汇总【安卓入门七】
- 段和页区别
- 表现。。
- Oracle day3
- Oracle day4
- 为自己的Ogre 应用程序添加 CEGUI应用 (四部曲)
- 使用javascript实现单选及多选的向右和向左移动
- int getchar(void);