- 浏览: 5776881 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (890)
- WindowsPhone (0)
- android (88)
- android快速迭代 (17)
- android基础 (34)
- android进阶 (172)
- android高级 (0)
- android拾遗 (85)
- android动画&效果 (68)
- Material Design (13)
- LUA (5)
- j2me (32)
- jQuery (39)
- spring (26)
- hibernate (20)
- struts (26)
- tomcat (9)
- javascript+css+html (62)
- jsp+servlet+javabean (14)
- java (37)
- velocity+FCKeditor (13)
- linux+批处理 (9)
- mysql (19)
- MyEclipse (9)
- ajax (7)
- wap (8)
- j2ee+apache (24)
- 其他 (13)
- phonegap (35)
最新评论
-
Memories_NC:
本地lua脚本终于执行成功了,虽然不是通过redis
java中调用lua脚本语言1 -
ZHOU452840622:
大神://处理返回的接收状态 这个好像没有监听到 遇 ...
android 发送短信的两种方式 -
PXY:
拦截部分地址,怎么写的for(int i=0;i<lis ...
判断是否登录的拦截器SessionFilter -
maotou1988:
Android控件之带清空按钮(功能)的AutoComplet ...
自定义AutoCompleteTextView -
yangmaolinpl:
希望有表例子更好。。。,不过也看明白了。
浅谈onInterceptTouchEvent、onTouchEvent与onTouch
Android TabWidget/TabHost有两种使用方法:
第一种:使用系统自带写好的TabHost(及继承自TabActivity类)具体代码如下:
第二种:就是定义我们自己的tabHost:不用继承TabActivity,具体代码如下:
注意:第二种方法时布局文件中的TabWidget的id必须定义为:android:id="@android:id/tabs",FrameLayout的id必须定义为:android:id="@android:id/tabcontent" 其它控件没有限制,否则报错。
【Android进阶】嵌套TabHost (TabHost中放TabHost,类似二级目录、二级树)
http://blog.csdn.net/feng88724/archive/2011/02/23/6203358.aspx
第一种:使用系统自带写好的TabHost(及继承自TabActivity类)具体代码如下:
<?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/tab1" android:layout_width="fill_parent" android:layout_height="fill_parent" androidrientation="vertical"> <TextView android:id="@+id/TextView1" android:text="This is a tab1" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> </LinearLayout> <LinearLayout android:id="@+id/tab2" android:layout_width="fill_parent" android:layout_height="fill_parent" androidrientation="vertical"> <TextView android:id="@+id/TextView2" android:text="This is a tab2" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> </LinearLayout> <LinearLayout android:id="@+id/tab3" android:layout_width="fill_parent" android:layout_height="fill_parent" androidrientation="vertical"> <TextView android:id="@+id/TextView3" android:text="This is a tab3" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> </LinearLayout> </FrameLayout>
package com.Aina.Android; import android.app.AlertDialog; import android.app.Dialog; import android.app.TabActivity; import android.content.DialogInterface; import android.os.Bundle; import android.view.LayoutInflater; import android.widget.TabHost; public class Test_TabWidget extends TabActivity { /** Called when the activity is first created. */ private TabHost tabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.main); tabHost = this.getTabHost(); LayoutInflater li = LayoutInflater.from(this); li.inflate(R.layout.main, tabHost.getTabContentView(), true); tabHost.addTab(tabHost.newTabSpec("Tab_1").setContent(R.id.tab1) .setIndicator("TAB1", this.getResources().getDrawable(R.drawable.img1))); tabHost.addTab(tabHost.newTabSpec("Tab_2").setContent(R.id.tab2) .setIndicator("TAB2", this.getResources().getDrawable(R.drawable.img2))); tabHost.addTab(tabHost.newTabSpec("Tab_3").setContent(R.id.tab3) .setIndicator("TAB3", this.getResources().getDrawable(R.drawable.img3))); tabHost.setCurrentTab(1); // tabHost.setBackgroundColor(Color.GRAY); tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { public void onTabChanged(String tabId) { Dialog dialog = new AlertDialog.Builder(Test_TabWidget.this) .setTitle("提示").setMessage( "选中了" + tabId + "选项卡").setIcon(R.drawable.icon).setPositiveButton("确定", new DialogInterface.OnClickListener(){ public void onClick(DialogInterface dialog, int which) { // TODO Auto-generated method stub } }).create(); dialog.show(); } }); } }
第二种:就是定义我们自己的tabHost:不用继承TabActivity,具体代码如下:
<?xml version="1.0" encoding="utf-8"?> <TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/TabHost01" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/LinearLayout1" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:text="one" android:id="@+id/TextView01" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TextView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="two" android:id="@+id/TextView02" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> </LinearLayout> <LinearLayout android:id="@+id/LinearLayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:text="three" android:id="@+id/TextView03" android:layout_width="fill_parent" android:layout_height="wrap_content"> </TextView> </LinearLayout> </FrameLayout> </LinearLayout> </TabHost>
package com.Aina.Android; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; import android.widget.TabHost; public class Test_TabHost extends Activity { /** Called when the activity is first created. */ private TabHost tabHost; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try{ tabHost = (TabHost) this.findViewById(R.id.TabHost01); tabHost.setup(); tabHost.addTab(tabHost.newTabSpec("tab_1") .setContent(R.id.LinearLayout1) .setIndicator("TAB1",this.getResources().getDrawable(R.drawable.img1))); tabHost.addTab(tabHost.newTabSpec("tab_2") .setContent(R.id.LinearLayout2).setIndicator("TAB2", this.getResources().getDrawable(R.drawable.img2))); tabHost.addTab(tabHost.newTabSpec("tab_3") .setContent(R.id.LinearLayout3).setIndicator("TAB3", this.getResources().getDrawable(R.drawable.img3))); tabHost.setCurrentTab(1); }catch(Exception ex){ ex.printStackTrace(); Log.d("EXCEPTION", ex.getMessage()); } } }
注意:第二种方法时布局文件中的TabWidget的id必须定义为:android:id="@android:id/tabs",FrameLayout的id必须定义为:android:id="@android:id/tabcontent" 其它控件没有限制,否则报错。
【Android进阶】嵌套TabHost (TabHost中放TabHost,类似二级目录、二级树)
http://blog.csdn.net/feng88724/archive/2011/02/23/6203358.aspx
发表评论
-
http://www.android-studio.org/
2018-08-06 09:25 0http://www.android-studio.org/ ... -
SlidingDrawer源码
2012-03-14 10:13 3772我把SlidingDrawer源码提了出来,希望对1.5的朋友 ... -
简单拖动效果(带Cache,需要完善)
2011-10-13 15:10 4181如何去实现一个具有幻象的拖拽效果? 所谓”幻象“就是当你按下去 ... -
Android Activity中启动另一应用程序的方法,无需得到类名
2011-08-02 14:46 17196在网上搜索了一会相关的实现代码,发现所有的文章都说是需要包名和 ... -
java-universal-tween-engine,一个动画系统库
2011-06-29 09:21 6698http://code.google.com/p/java-u ... -
网上发现的一个android UI包
2011-05-24 12:21 4048里面有些UI和效果 -
android中使用代码启动其他程序
2011-04-29 23:15 5221你要訪問其他的程序,那麼這個程序要先裝載到模擬器或真機上面,因 ... -
listView背景问题以及限制editText字数以及如果想通知别人已经不能在写
2011-04-29 22:44 31601.在listView设置好背景之后 你如果点击空白出 你会发 ... -
Android键盘和触摸事件处理
2011-04-29 22:32 6963activity和VIEW都能接收触摸和按键,如果响应事件只需 ... -
Android的绘制文本对象FontMetrics的介绍及绘制文本
2011-04-29 22:29 11459一。Android绘制文本对象FontMetrics介绍 ... -
Android View 拖动&插入
2011-04-29 22:20 3504View 拖动&插入 即: 支持 拖动图标 然后 ... -
使TextView文本可以水平和垂直滚动
2011-04-29 21:59 14334在做一个小的电子书程序,要求电子书具有放大缩小的功能,所以肯定 ... -
ArrayAdapter源码
2011-04-29 12:29 6262看看人家怎么写的。 /* * Copyright (C ... -
Android下获取开机时间
2011-04-02 21:51 6184找了一圈没发现能得到开机启动时间资料,于是乎突发奇想,得到了解 ... -
AutoCompleteTextView连接到数据库
2011-03-30 20:49 4653AutoCompleteTextView可以根据输入 ... -
改变屏幕Brightness(亮度)
2011-03-30 12:48 4563http://www.eoeandroid.com/forum ... -
android 拖拽图片&拖动浮动按钮到处跑
2011-02-24 20:55 31701来自老外: import android.app.Acti ... -
拖动一个控件在另一个控件(layout)上,并固定位置在几个位置显示
2011-02-24 20:51 5847实现效果: 鼠标拖动btn SSS,SSS在水平的layo ... -
Handler与Message类,实现n秒后无操作自动消失功能
2011-02-24 20:45 4593实现功能:某控件不操作10秒后,自动消失。如照相机变焦条出现后 ... -
带删除按钮的ListView
2011-02-24 10:33 6112不用说了,上图先: import java.util.A ...
相关推荐
Tabwidget的不同tab指向不同的Activity
接着上一个资源,两个资源实现的功能都是一样的,都是TabHost选项卡,详细请看http://blog.csdn.net/shuanyang/article/details/27819203
TabHost+TabWidget+FrameLayout实现主页面实现底部栏;
Android_TabHost_TabWidget选项卡总结
Android TabHost TabWidget 切换卡
自定义样式的tabHost,包含两种方式:activity对象作为内容、View对象作为内容。注释详细
本文实例讲述了Android编程设置TabHost当中字体的方法。分享给大家供大家参考,具体如下: TabWidget tw=this.getTabWidget();//设置TabHost当中的内容的方法 for(int i=0;i<tw.getChildCount();i++){ //设置...
先看效果: 京东商城底部菜单栏 新浪微博底部菜单栏 本次学习效果图: 第一,主布局文件(启动页main.xml,位于res/layout目录下)代码 <...xml version=....android:id=@+id/tabhost
<TabHost android:id="@android:id/tabhost" tools:context="com.example.ydc.filemanager.MainActivity"> <LinearLayout android:background="@drawable/login_bg" android:orientation="vertical"> <TabWidget ...
TabHost使用以及源码分析。 对应的文章为:http://blog.csdn.net/yanbin1079415046/article/details/7973022
Android TabHost示例使用XML TabHost和TabWidget的Android Tab示例。 单击下面的链接以获取教程。演示版![ALT文本( “可选标题”)
TabHost控件->TabWidget(必须命名为tabs)->FrameLayout(必须命名为tabcontent)。 先来贴出本例运行的截图: main.xml的源码如下: <?xml version=1.0 encoding=utf-8?> <TabHost android:layout_width=...
android tabwidget 嵌套的使用,主要在子页面中也能很好的实现界面的切换
Android入门第十一篇之TabHost,TabWidget.docx
http://blog.csdn.net/birdno1/article/details/50516725 通过自定义view解决tabwidget下划线颜色问题
两种实现方式,一种是将每个Tab的布局嵌在TabHost中的FrameLayout中,每个Tab的内容布局与显示都在FrameLayout中进行,缺点是布局会显得很臃肿;一种是每个Tab从FrameLayout中独立出来,以Activity呈现,这样使得每...
2.保证无毒 3.简单,方便,实用 4.实例可以自行改用 5.如有非法,本人无法律责任,由改动代码人负责! 6.需要更多本人作品,查找标签“朱建强” 7.请下载,杀毒后再使用!
要使用TabHost,首先要通过getTabHost方法获取TabHost的对象,然后通过addTab方法来向TabHost中添加Tab,当然每个Tab在切换时都会产生一个事件,要捕捉这个事件,需要设置TabActivity的事件监听...
TabWidget控件.