采用TabHost和RadioButton实现页面导航效果
实现的效果不解释,主要是记录一下代码
先看一下xml布局:
<?xml version="1.0" encoding="UTF-8"?><TabHost xmlns:android="schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="fill_parent" > <LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="0.0dip" android:layout_weight="1.0" /> <TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_weight="0.0" android:background="@drawable/maintab_toolbar_bg" android:visibility="gone" /> <RadioGroup android:id="@id/main_radio" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_gravity="bottom" android:background="@drawable/maintab_toolbar_bg" android:gravity="center_vertical" android:orientation="horizontal" > <RadioButton android:id="@id/radio_contact" style="@style/main_tab_bottom" android:drawableTop="@drawable/main_tab_contact_checked" android:text="@string/radio_contact" /> <RadioButton android:id="@id/radio_calllist" style="@style/main_tab_bottom" android:layout_marginTop="0dip" android:layout_marginBottom="0dip" android:drawableTop="@drawable/main_tab_calllist_normal" android:text="@string/radio_calllist" /> <RadioButton android:id="@id/radio_sms" style="@style/main_tab_bottom" android:layout_marginTop="0dip" android:layout_marginBottom="0dip" android:drawableTop="@drawable/main_tab_sms_normal" android:text="@string/radio_sms" /> <RadioButton android:id="@id/radio_setting" style="@style/main_tab_bottom" android:layout_marginTop="0dip" android:layout_marginBottom="0dip" android:drawableTop="@drawable/nav_menu_me" android:text="@string/radio_setting" /> </RadioGroup> </LinearLayout></TabHost>
二、MainTabActivity
package com.gs.app.main;import android.app.TabActivity;import android.content.Intent; import android.os.Bundle;import android.view.Window;import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.RadioButton;import android.widget.TabHost; import com.gs.Appblue.R;import com.gs.app.contact.ContactsListActivity; import com.gs.app.contact.RecentCallsListActivity; import com.gs.app.setting.Setting; import com.gs.app.sms.ActSMSList; public class MainTabActivity extends TabActivity implementsOnCheckedChangeListener {private TabHost mTabHost;private Intent mContactIntent;private Intent mCallLogIntent;private Intent mSmsIntent; private Intent mSetIntent;public void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE);setContentView(R.layout.main_tab); this.mContactIntent = new Intent(this, ContactsListActivity.class); this.mCallLogIntent = new Intent(this, RecentCallsListActivity.class); this.mSmsIntent = new Intent(this, ActSMSList.class); this.mSetIntent = new Intent(this, Setting.class); ((RadioButton) findViewById(R.id.radio_contact)).setOnCheckedChangeListener(this); ((RadioButton) findViewById(R.id.radio_calllist)).setOnCheckedChangeListener(this); ((RadioButton) findViewById(R.id.radio_sms)).setOnCheckedChangeListener(this); ((RadioButton) findViewById(R.id.radio_setting)).setOnCheckedChangeListener(this); setupIntent();}private void setupIntent() {this.mTabHost = getTabHost(); TabHost localTabHost = this.mTabHost; localTabHost.addTab(buildTabSpec("A_TAB", R.string.radio_contact,R.drawable.main_tab_contact_normal, this.mContactIntent));localTabHost.addTab(buildTabSpec("B_TAB", R.string.radio_calllist,R.drawable.main_tab_calllist_normal, this.mCallLogIntent));localTabHost.addTab(buildTabSpec("C_TAB", R.string.radio_sms,R.drawable.main_tab_sms_normal, this.mSmsIntent));localTabHost.addTab(buildTabSpec("D_TAB", R.string.radio_setting,R.drawable.main_tab_setting_normal, this.mSetIntent)); localTabHost.setCurrentTab(0);}@Overridepublic void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {if (isChecked) {switch (buttonView.getId()) {case R.id.radio_contact:this.mTabHost.setCurrentTabByTag("A_TAB"); break;case R.id.radio_calllist:this.mTabHost.setCurrentTabByTag("B_TAB");break;case R.id.radio_sms:this.mTabHost.setCurrentTabByTag("C_TAB");break;case R.id.radio_setting:this.mTabHost.setCurrentTabByTag("D_TAB");break;}}}private TabHost.TabSpec buildTabSpec(String tag, int resLabel, int resIcon,final Intent content) {return this.mTabHost.newTabSpec(tag).setIndicator(getString(resLabel),getResources().getDrawable(resIcon)).setContent(content);}}

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

记事本++7.3.1
好用且免费的代码编辑器

SublimeText3汉化版
中文版,非常好用

禅工作室 13.0.1
功能强大的PHP集成开发环境

Dreamweaver CS6
视觉化网页开发工具

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

你可能遇到过智能手机屏幕出现绿色线条的问题,即使没见过,也一定在网络上看到过相关图片。那么,智能手表屏幕变白的情况你遇见过吗?4月2日,CNMO从外媒了解到,一名Reddit用户在社交平台上分享了一张图片,展示了三星Watch系列智能手表屏幕变白的情况。该用户写道:"我离开时正在充电,回来时就这样了,我尝试重启,但重启过程中屏幕还是这样。"三星Watch智能手表屏幕变白这位Reddit用户并未指明这款智能手表的具体型号。不过,从图片上看,应该是三星Watch5。此前,另一位Reddit用户也报告

是否要复制MicrosoftWord中的页面,并保持格式不变?这是一个聪明的想法,因为当您想要创建特定文档布局或格式的多个副本时,在Word中复制页面可能是一种有用的节省时间的技术。本指南将逐步引导您在Word中复制页面的过程,无论是创建模板还是复制文档中的特定页面。这些简单的说明旨在帮助您轻松地重新制作页面,省去从头开始的麻烦。为什么要在MicrosoftWord中复制页面?在Word中复制页面非常有益的原因有以下几点:当您有一个具有特定布局或格式的文档要复制时。与从头开始重新创建整个页面不同

说起阿萨辛ASSASSIN,相信玩家们一定会想到《刺客信条》中的各位刺客大师,不仅身手了得,而且"躬身于黑暗、服务于光明"的信条,与国内知名机箱/电源/散热器品牌九州风神(DeepCool)旗下的阿萨辛ASSASSIN系列旗舰级风冷散热器不谋而合。最近,该系列的最新产品阿萨辛ASSASSIN4S重磅上线,"西装刺客,再进阶"为高级玩家带来全新的风冷散热体验。外观一览细节满满阿萨辛4S散热器采用双塔构造+单风扇内嵌设计,外面包覆立方体造型的整流罩,整体感极强,并提供白、黑两种配色可选,满足不同色系

随着春天的到来,万物复苏,一切都充满了生机与活力。在这个美好的季节里,如何为家居生活增添一抹别样的色彩?哈趣H2投影仪,以其精致的设计和超高的性价比,成为了这个春天里不可或缺的一道亮丽风景。这款H2投影仪小巧玲珑却不失时尚。无论是放在客厅的电视柜上,还是卧室的床头柜旁,都能成为一道亮丽的风景线。它的机身采用了奶白色的磨砂质地,这种设计不仅让投影仪的外观更显高级,同时也增加了触感的舒适度。米色仿皮纹材质,更是为整体外观增添了一抹温馨与雅致。这种色彩与材质的搭配,既符合现代家居的审美趋势,又能够融入

页面刷新在我们日常的网络使用中非常常见,当我们访问一个网页后,有时候会遇到一些问题,比如网页加载不出来或者显示不正常等。这时候我们通常会选择刷新页面来解决问题,那么如何快速地刷新页面呢?下面我们就来探讨一下页面刷新的快捷键。页面刷新快捷键是一种通过键盘操作来快速刷新当前网页的方法。在不同的操作系统和浏览器中,页面刷新的快捷键可能有所不同。下面我们以常见的W

一个可以自动分析PDF、网页、海报、Excel图表内容的大模型,对于打工人来说简直不要太方便。上海AILab,香港中文大学等研究机构提出的InternLM-XComposer2-4KHD(简写为IXC2-4KHD)模型让这成为了现实。相比于其他多模态大模型不超过1500x1500的分辨率限制,该工作将多模态大模型的最大输入图像提升到超过4K(3840x1600)分辨率,并支持任意长宽比和336像素~4K动态分辨率变化。发布三天,该模型就登顶HuggingFace视觉问答模型热度榜单第一。轻松拿捏

ITX平台以小巧的身形吸引了不少追求极致和独特美感的玩家,随着制程的提升和技术的进步,英特尔第14代酷睿和RTX40系显卡都可以在ITX平台中发挥实力,游戏玩家也对SFX电源有了更高的要求。游戏爱好者航嘉推出新的MX系列电源,在满足高性能需求的ITX平台中,MX750P全模组电源的定额功率高达750W,同时通过了80PLUS白金级认证。以下我们就带来这款电源的评测。航嘉MX750P全模组电源采用了简约时尚的设计理念,共有黑白两款供玩家选择,均采用磨砂表面处理,搭配银灰色和红色的字体有很好的质感,

在当下科技飞速发展的时代,笔记本电脑已经成为人们日常生活和工作中不可或缺的重要工具。对于那些对性能有高要求的玩家而言,拥有配置强大、性能出色的笔记本电脑才能满足其硬核需求。七彩虹隐星P15笔记本电脑凭借其卓越性能和令人惊艳的设计,成为了未来的引领者,堪称硬核笔记本的典范。七彩虹隐星P1524配备了13代英特尔酷睿i7处理器和RTX4060LaptopGPU,外观采用更时尚的宇宙飞船设计风格,同时在细节表现上也有出色表现。让我们先来了解一下这款笔记本的特点。至高搭载英特尔酷睿i7-13620H处理
