好久没上了,今天弄个小例子,关于标题图片变化的例子,直接上例子。
tabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { if(tabId.equals("tab1")){ //getChildAt(i),里面的i表示对应的tab。 ImageView iv = (ImageView) getTabWidget().getChildAt(0).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.basicinfo2)); iv = (ImageView) getTabWidget().getChildAt(1).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.dise1)); iv = (ImageView) getTabWidget().getChildAt(2).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.manage1)); iv = (ImageView) getTabWidget().getChildAt(3).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.service1)); }else if(tabId.equals("tab2")){ ImageView iv = (ImageView) getTabWidget().getChildAt(0).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.basicinfo1)); iv = (ImageView) getTabWidget().getChildAt(1).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.dise2)); iv = (ImageView) getTabWidget().getChildAt(2).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.manage1)); iv = (ImageView) getTabWidget().getChildAt(3).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.service1)); }else if(tabId.equals("tab3")){ ImageView iv = (ImageView) getTabWidget().getChildAt(0).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.basicinfo1)); iv = (ImageView) getTabWidget().getChildAt(1).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.dise1)); iv = (ImageView) getTabWidget().getChildAt(2).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.manage2)); iv = (ImageView) getTabWidget().getChildAt(3).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.service1)); }else if(tabId.equals("tab4")){ ImageView iv = (ImageView) getTabWidget().getChildAt(0).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.basicinfo1)); iv = (ImageView) getTabWidget().getChildAt(1).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.dise1)); iv = (ImageView) getTabWidget().getChildAt(2).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.manage1)); iv = (ImageView) getTabWidget().getChildAt(3).findViewById(android.R.id.icon); iv.setImageDrawable(getResources().getDrawable(R.drawable.service2)); } } });
下面看下效果:
相关推荐
tabhost页面跳转需要用到的tabhost单例模式小例子,也有tabhost底部的布局
android tabhost activitygroup 源码 分享给有需要的朋友们
TabHost例子 不使用TabActivity实现
传了玩玩,适合刚学习的朋友~~~~~~~~~~~~~~~~
一个简单的实现例子,底部TabHost,内部加载Activity。
Android TabHost ListView初学者的实例代码
NULL 博文链接:https://dengyin2000.iteye.com/blog/1632740
自定义TabHost 图片在左文字在右 可以结合修改为新的布局
tabhost中嵌套一个tabhost。
Android Tabhost 实例demo 自定义Tabhost实现实例。
配套博客 对TabHost选项卡组件进行了详细解析,比较使用的例子
Android系统自带的TabHost控件很难看,这是一个自定义TabHost例子,显示在底部,类似于微博下面的Tab选项卡
TabHost+ViewPager实现滑动tabhost, viewPager;tabhost;滑动;源码
自定义TabHost各种经典实现,突破了传统的固定模式,内有word文档代码详解!
现今很流行的 TabHost的各种实现方式的代码
TabHost布局的框架,点击button按钮切换页面、随即更改字体颜色和背景图片。
Android 嵌套TabHost示例. 两层TabHost嵌套,实现的效果类似网页上的二级菜单栏。
NULL 博文链接:https://whoyuhui.iteye.com/blog/1167378
Android TabHost TabActivity TabHost的简单使用