android TabActivity用法
来源:互联网 发布:2016网络直播红人排名 编辑:程序博客网 时间:2024/06/06 15:42
http://wenku.it168.com/d_000787857.shtml
1.效果图:
2.代码:
MainActivity.java:
package com.example.testtab2;import android.os.Bundle;import android.app.Activity;import android.app.TabActivity;import android.content.Intent;import android.view.LayoutInflater;import android.view.Menu;import android.widget.TabHost;public class MainActivity extends TabActivity {@Overrideprotected void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);//setContentView(R.layout.activity_main);TabHost th=getTabHost(); LayoutInflater.from(this).inflate(R.layout.activity_main,th.getTabContentView(),true);th.addTab(th.newTabSpec("all").setIndicator("aaaaa").setContent(new Intent(this,page1.class)));th.addTab(th.newTabSpec("ok").setIndicator("bbbbb").setContent(new Intent(this,page2.class)));//th.addTab(th.newTabSpec("cancel").setIndicator("ccccc").setContent(R.id.TextView03));}@Overridepublic boolean onCreateOptionsMenu(Menu menu){// Inflate the menu; this adds items to the action bar if it is// present.getMenuInflater().inflate(R.menu.main, menu);return true;}}
activity_main.xml:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="@dimen/activity_vertical_margin" android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" tools:context=".MainActivity" > <TabHost android:id="@+id/TabHost01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TabHost> </FrameLayout>
page1.java:
package com.example.testtab2;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;public class page1 extends Activity {Button bt;@Overrideprotected void onCreate(Bundle savedInstanceState){// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.page1);bt= (Button)findViewById(R.id.button1);bt.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v){// TODO Auto-generated method stubSystem.out.println("click page1 button1");}});}}
page1.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="tab test Large Text" android:textAppearance="?android:attr/textAppearanceLarge" /> <Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button" /></LinearLayout>
page2.java:
package com.example.testtab2;import android.app.Activity;import android.os.Bundle;public class page2 extends Activity{@Overrideprotected void onCreate(Bundle savedInstanceState){// TODO Auto-generated method stubsuper.onCreate(savedInstanceState);setContentView(R.layout.page2);}}
page2.xml:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="page2 test Large Text" android:textAppearance="?android:attr/textAppearanceLarge" /></LinearLayout>
- android TabActivity用法
- Android中TabActivity用法大全
- android中TabActivity的用法
- TabActivity用法
- android:TabActivity
- TabActivity简单用法
- TabActivity牛逼用法
- TabActivity用法解析
- Android TabActivity的嵌套
- Android TabActivity Essentials
- android开发之TabActivity
- android的TabActivity
- Android之TabActivity
- Android下实现TabActivity
- Android TabActivity 按键响应
- Android TabActivity的生命周期
- android的TabActivity
- android的TabActivity
- Navigation
- LEADTOOLS解决表单识别的相关策略介绍
- 【C++ Primer】两个类相互包含的求解策略
- VS2010学习笔记之一:新建单文档应用程序资源里没有ToolBar
- 浅谈SQL Server中统计对于查询的影响
- android TabActivity用法
- Tutorial 1 Create a Simple web dynpro application
- 移植wireless tools (iwpriv, iwconfig, iwgetid, iwevents, iwspy, iwlist)到Android
- 面试题之又见排序分析---mark没看
- java ssh项目启动异常说明
- 改善虚拟服务器的存储性能
- JSON序列化与解析(原生JS方法)【IE6和chrome测试通过】
- TABLE CONTROL 隐藏column
- labview cvi 关于库文件