- 浏览: 126606 次
- 性别:
- 来自: 南京
最新评论
-
cenyi2012:
来个图文并茂不是更好。。。
TabHost两种实现方式 -
youlingxifeng:
谢谢了,很受用,你有没有遇到过这样的问题啊build/core ...
Android源码编译全过程 -
flower_is:
不错不错!
Android的selector,背景选择器 -
yang668:
很好 真心的谢谢
反编译apk -
windloverain:
编译2.3的代码需要用1.6的sdk
另外,安装完java s ...
Android源码编译全过程
第一种:继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost。只要定义具体Tab内容布局就行了.
xml布局:
第二种:不用继承TabActivity,在布局文件中定义TabHost即可,但是TabWidget的id必须是
@android:id/tabs,FrameLayout的id必须是@android:id/tabcontent。TabHost的id可以自定义.
xml布局:
xml布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:id="@+id/widget_layout_Blue" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <EditText android:id="@+id/widget34" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="EditText" android:textSize="18sp"> </EditText> <Button android:id="@+id/widget30" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Button"> </Button> </LinearLayout> <LinearLayout android:id="@+id/widget_layout_red" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <AnalogClock android:id="@+id/widget36" android:layout_width="wrap_content" android:layout_height="wrap_content"> </AnalogClock> </LinearLayout> <LinearLayout android:id="@+id/widget_layout_green" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <RadioGroup android:id="@+id/widget43" android:layout_width="166px" android:layout_height="98px" android:orientation="vertical"> <RadioButton android:id="@+id/widget44" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton"> </RadioButton> <RadioButton android:id="@+id/widget45" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="RadioButton"> </RadioButton> </RadioGroup> </LinearLayout> </FrameLayout> java代码: super.onCreate(savedInstanceState); myTabhost=this.getTabHost(); //get Tabhost LayoutInflater.from(this).inflate(R.layout.main, myTabhost.getTabContentView(), true); myTabhost.setBackgroundColor(Color.argb(150, 22, 70, 150)); myTabhost .addTab(myTabhost.newTabSpec("One")// make a new Tab .setIndicator("A") // set the Title and Icon .setContent(R.id.widget_layout_Blue)); // set the layout myTabhost .addTab(myTabhost.newTabSpec("Two")// make a new Tab .setIndicator("B", getResources().getDrawable(R.drawable.mumule)) // set the Title and Icon .setContent(R.id.widget_layout_green)); // set the layout myTabhost .addTab(myTabhost.newTabSpec("Three")// make a new Tab .setIndicator("C", getResources().getDrawable(R.drawable.notepad)) // set the Title and Icon .setContent(R.id.widget_layout_red));
第二种:不用继承TabActivity,在布局文件中定义TabHost即可,但是TabWidget的id必须是
@android:id/tabs,FrameLayout的id必须是@android:id/tabcontent。TabHost的id可以自定义.
xml布局:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/hometabs" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabHost android:id="@+id/tabhost" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <TabWidget android:id="@android:id/tabs" android:orientation="horizontal" android:layout_width="wrap_content" android:layout_height="wrap_content"> </TabWidget> <FrameLayout android:id="@android:id/tabcontent" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:id="@+id/view1" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <TextView android:id="@+id/view2" android:layout_width="fill_parent" android:layout_height="fill_parent"/> <TextView android:id="@+id/view3" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </FrameLayout> </LinearLayout> </TabHost> </LinearLayout> java代码: protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.hometabs); TabHost tabHost = (TabHost) findViewById(R.id.tabhost); tabHost.setup(); TabWidget tabWidget = tabHost.getTabWidget(); tabHost.addTab(tabHost.newTabSpec("tab1") .setIndicator("tab1", getResources().getDrawable(R.drawable.mumule)) .setContent(R.id.view1)); tabHost.addTab(tabHost.newTabSpec("tab3") .setIndicator("tab3") .setContent(R.id.view3)); tabHost.addTab(tabHost.newTabSpec("tab2") .setIndicator("tab2") .setContent(R.id.view2)); final int tabs = tabWidget.getChildCount(); Log.i(TAG, "***tabWidget.getChildCount() : " + tabs); final int tabWidth = 90; final int tabHeight = 45; for (int i = 0; i < tabs; i++) { /* final View view = tabWidget.getChildAt(i); view.getLayoutParams().width = tabWidth; view.getLayoutParams().height = tabHeight; final TextView tv = (TextView) view.findViewById(android.R.id.title); tv.setTextColor(this.getResources().getColorStateList(android.R.color.black)); MarginLayoutParams tvMLP = (MarginLayoutParams)tv.getLayoutParams(); tvMLP.bottomMargin = 8;*/ } }
- Tab.rar (130.9 KB)
- 下载次数: 1250
发表评论
-
system挂载为rw
2011-07-28 15:07 2788adb shell #su #mount -o remou ... -
制作TextView的倒影
2011-07-19 13:52 2026package com.javaeye.graphics; ... -
Androkd开发坏境配置以及常用插件
2011-06-21 10:39 1107步骤: 1、安装jdk,并配置环境变量 2、解压android ... -
Android的selector,背景选择器
2011-05-22 11:50 1716首先android的selector是在drawable/xx ... -
PUSH机制
2011-04-20 13:54 12711、长连接 2、Android and XMPP htt ... -
ListView快速滑动搜索
2011-04-14 10:16 1233相关资料: Android-ListView快速滚动示例增加首 ... -
Android源码编译全过程
2011-03-18 09:39 82641, ubuntu 下源码编译 最好切换到root用户下进行操 ... -
测试环境Hosts设置
2011-02-25 18:25 1738设置方法: //启动虚拟手机并更改分区大小为128M emul ... -
Activity的launchMode
2011-01-16 17:02 798请看博客:http://marshal.easymorse.c ... -
android多分辨力支持 密度与分辨力
2010-12-29 15:37 1209关于Android的分辨率支持,为大家翻译官方文档 看世界杯的 ... -
用shape美化控件
2010-12-29 10:34 908如果你对Android系统自带的UI控件感觉不够满意, ... -
Android知识积累
2010-12-28 13:44 988引用系统资源: android:textColor=& ... -
自定义对话框Dialog
2010-12-16 16:55 1491提醒对话框: 布局文件:alertdialog.xml < ... -
Dialog
2010-12-16 14:45 10631. 创建对话框 1. Showing ... -
Android 文件系统的结构
2010-11-06 22:56 10131、Android 文件系统的结构 Android源码编译后 ... -
DB和File工具类
2010-11-01 15:46 1510DB工具类: import java.io.B ... -
打造自己的动画效果
2010-10-29 14:25 945当我们的软件基本功能都实现了之后,我们是不是还可以把它做的更好 ... -
画图,Shader Path
2010-10-28 16:42 1249package com.javaeye.android.my; ... -
Google API应用
2010-10-27 16:21 1544获取Location Provider: android lo ... -
使用SoundPool播放游戏音效
2010-10-12 15:51 1748在Android开发中我们经常使用MediaPlayer来播放 ...
相关推荐
TabHost的两种实现方式
两种特殊的选项卡的实现的源代码,其中一种是模仿网易新闻应用的底部导航栏的写的。
类似新浪布局的两种不同实现方法,两种标签页面的实现方法。
TabHost的实现分为两种,一个是不继承TabActivity,一个是继承自TabActivity;当然了选用继承自TabActivity的话就相对容易一些,下面来看看分别是怎样来实现的吧。 方法一、定义tabhost:不用继承TabActivity 1、...
使用Tablayout和RadioGroup两种方式实现底部导航,使用Tablayout实现顶部导航
底部导航栏的两种实现 博客:https://blog.csdn.net/qq941263013/article/details/81136064 第一种:纯小图+文字; 第二种:中间为图片的底部导航栏;
Android开发过程中,特别...这里我先介绍前面两种实现方式,后面两种后期再贴出实现方式。 一、使用TabLayout + Fragment + ViewPager实现 1、实现步骤: (1)、布局文件中定义TabLayout控件 (2)、定义切换的每个Fragm
FragmentTabHostTwoImplementionsAndroid 底部导航栏的两种实现(通过FragmentTabHost + Fragment实现),主要功能包括:FragmentTabHost的使用、图片选择器、文字选择器、沉浸式状态栏、带图片的底部导航栏等。...
两种实现方式,一种是将每个Tab的布局嵌在TabHost中的FrameLayout中,每个Tab的内容布局与显示都在FrameLayout中进行,缺点是布局会显得很臃肿;一种是每个Tab从FrameLayout中独立出来,以Activity呈现,这样使得每...
实现方式 实现的方式有很多种 这里总结最常见的几种方式,以后再添加其他的。 viewPager + RadioGroup viewPager + FragmentTabHost viewpager +TabLayout viewPager+RadioGroup 感觉这是最简单的一个了,我也就不贴...
它的实现主要是利用了TabHost类。 TabHost说明 TabHost是一个标签窗口的容器。 一个TabHost对象包含两个子元素对象: 一个对象是tab标签集合(TabWidget),用户点击它们来选择一个特定的标签; 另一个是FrameLayout...
为了给Tab增加菜单,有如下两种方法: 1. 主事件继承Activity。这样就可以在主事件中直接重写OnCreateOptionsMenu方法,为程序添加Menu。如果每个Tab需要有不同的Menu,可以为TabHost添加一个OnTabChangedListener,...
81、获得屏幕像素的两种方法 126 82、ShowDialog(int id); 126 83、透明效果的实现 128 84、根据网络或GPS获得经纬度 128 85、TextView 130 90、获取存储卡和手机内部存储空间 130 91、获得当前应用的UID 131 92、...
两分钟彻底让你明白Android Activity生命周期(图文)! Android 图形系统剖析 Android 立体效果图片 NDK动态库的调用 Android 姿态传感器 Android 很酷的图像旋转 Android 添加音频 在Android中实现多线程断点下载 ...
|--监听之单击监听的两种定义 |--监听之双击监听 |--监听之电话状态监听 |--监听之触摸监听 |--短信之根据id删除及查询短信 |--短信发送小demo |--短信的截取 |--系统之SD卡清理 |--系统之获取所有开机启动应用 |--...
4.5.2、menu实现的两种方法 58 4.5.3、自定义MENU背景 62 4.5.4、触发menu 64 4.5.5、Context Menu和Options Menu菜单的区别 64 4.5.6、Context menus for expandable lists 64 4.6、LISTVIEW 66 4.6.1、ListView...
4.5.2、menu实现的两种方法 58 4.5.3、自定义MENU背景 62 4.5.4、触发menu 64 4.5.5、Context Menu和Options Menu菜单的区别 64 4.5.6、Context menus for expandable lists 64 4.6、LISTVIEW 66 4.6.1、ListView...