本文实例为大家分享了Android仿新浪微博分页管理界面的具体代码,供大家参考,具体内容如下

多个activity分页管理,为了方便获取上下文,采用继承TabActivity的传统方法。

大致思路:使用RadioGroup点击触发不同的选卡项,选卡项绑定不同的activiity,进而进行分页管理。详解见注解。

/**

* 主Activity

* 通过点击RadioGroup下的RadioButton来切换不同界面

* Created by D&LL on 2016/7/20.

*/

public class MainActivity extends TabActivity {

//定义TabHost对象

private TabHost tabHost;

//定义RadioGroup对象

private RadioGroup radioGroup;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.tab_layout);

initView();

initData();

}

/**

* 初始化组件

*/

private void initView() {

//实例化TabHost,得到TabHost对象

tabHost = getTabHost();

//得到Activity的个数

int count = Constant.ConValue.mTabClassArray.length;

for (int i = 0; i < count; i++) {

//为每一个Tab按钮设置图标、文字和内容

TabSpec tabSpec = tabHost.newTabSpec(Constant.ConValue.mTextviewArray[i])

.setIndicator(Constant.ConValue.mTextviewArray[i]).setContent(getTabItemIntent(i));

//将Tab按钮添加进Tab选项卡中

tabHost.addTab(tabSpec);

}

//实例化RadioGroup

radioGroup = (RadioGroup) findViewById(R.id.main_radiogroup);

}

/**

* 初始化组件

*/

private void initData() {

// 给radioGroup设置监听事件

radioGroup.setOnCheckedChangeListener(new OnCheckedChangeListener() {

public void onCheckedChanged(RadioGroup group, int checkedId) {

switch (checkedId) {

case R.id.RadioButton0:

tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[0]);

break;

case R.id.RadioButton1:

tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[1]);

break;

case R.id.RadioButton2:

tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[2]);

break;

case R.id.RadioButton3:

tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[3]);

break;

case R.id.RadioButton4:

tabHost.setCurrentTabByTag(Constant.ConValue.mTextviewArray[4]);

break;

}

}

});

((RadioButton) radioGroup.getChildAt(0)).toggle();

}

/**

* 给Tab选项卡设置内容(每个内容都是一个Activity)

*/

private Intent getTabItemIntent(int index) {

Intent intent = new Intent(this, Constant.ConValue.mTabClassArray[index]);

return intent;

}

}

MainActivity布局文件tab_layout.xml. TabHost布局,添加一个TabWidget用于显示activity,下面是一个RadioGroup显示切换activity的按钮菜单。

android:id="@android:id/tabhost"

android:layout_width="fill_parent"

android:layout_height="fill_parent">

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:orientation="vertical">

android:id="@android:id/tabcontent"

android:layout_width="fill_parent"

android:layout_height="0.0dip"

android:layout_weight="1.0"/>

android:id="@android:id/tabs"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_weight="0.0"

android:visibility="gone"/>

android:id="@+id/main_radiogroup"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_gravity="bottom"

android:background="@drawable/tab_widget_background"

android:gravity="center_vertical"

android:orientation="horizontal"

android:padding="2dip">

android:id="@+id/RadioButton0"

style="@style/tab_item_background"

android:drawableTop="@drawable/tab_home"

android:text="主页"

android:textColor="#ffffff"/>

android:id="@+id/RadioButton1"

style="@style/tab_item_background"

android:drawableTop="@drawable/tab_msg"

android:text="评论"

android:textColor="#ffffff"/>

android:id="@+id/RadioButton2"

style="@style/tab_item_background"

android:drawableTop="@drawable/tab_write"

android:text="发微博"

android:textColor="#ffffff"/>

android:id="@+id/RadioButton3"

style="@style/tab_item_background"

android:drawableTop="@drawable/tab_me"

android:text="用户信息"

android:textColor="#ffffff"/>

android:id="@+id/RadioButton4"

style="@style/tab_item_background"

android:drawableTop="@drawable/tab_more"

android:text="更多"

android:textColor="#ffffff"/>

效果图:

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持找一找教程网。

Android新浪微博分页加载,Android仿新浪微博分页管理界面(3)相关推荐

  1. 微信小程序php分页加载,微信小程序分页加载

    分页加载功能大家遇到的应该会经常遇到,应用场景也很多,例如微博,QQ,微信朋友圈以及新闻类应用,都会有分页加载的功能,这不仅节省了我们用户的流量,还提升了用户体验.那么今天的这篇文章就是介绍微信小程序 ...

  2. Android新浪微博分页加载,Android仿新浪微博自定义ListView下拉刷新(4)

    自定义PullToRefreshListView继承ListView,在ListView头部添加一个下拉的头部布局.跟ListView用法完全一致. 此处详细介绍Adapter的详细代码. 1.首先给 ...

  3. android 模块自动加载,Android 之ko模块的自动加载

    最近在做一个触摸式遥控器,以控制Android TV,供应商提供了触摸板驱动的source code,我将其编译生成一个适合我们平台的ko模块.但是有个问题,每次用时,必须手动insmod进去,很麻烦 ...

  4. gif android 点击 加载,android 加载显示gif图片的解决方案

    使用方法: 1-把GifView.jar加入你的项目. 2-在xml中配置GifView的基本属性,GifView继承自View类,和Button.ImageView一样是一个UI控件.如: andr ...

  5. android自定义图片加载,Android自定义ProgressDialog加载图片

    为了提高用户体验,我们肯定希望该Dialog能更加炫酷,让用户看着更舒服.那如何做呢,当然是我们自己定义一个ProgressDialog了. 一.使用系统加载框 mDialog = new Progr ...

  6. android dagger2 懒加载,Android Dagger依赖注入框架浅析

    今天接触了Dagger这套android的依赖注入框架(DI框架),感觉跟Spring 的IOC差不多吧.这个框架它的好处是它没有采用反射技术(Spring是用反射的),而是用预编译技术,因为基于反射 ...

  7. android地图图片加载,Android图片加载解析之Bitmap

    写在前面的话,本篇文章是参考自<Android开发艺术探索>所写,看此书已是2015年的事情啦,由于独立开放项目,以至于对于Android原理性东西生疏,最近需要换工作,重新捡起此书,仍有 ...

  8. android 不重新加载,android – 返回Activity而不重新创建(不调用onCreate())

    在导航应用程序时无需完成()活动.相反,您可以维护您的Activity back-stack并仍然实现您的目标.假设你有4个这样的活动: A – > B – > C – > D. 其 ...

  9. Xamarin.Android 实现正在加载动画效果

    通过添加不同帧数的图片,来实现自己想要的动画效果正在加载... 第一步: Resources/drawable 目录下添加每一帧的图片,我设定了18帧 第二步:实现动画效果,drawable下新建页面 ...

  10. 深入理解Android Paging分页加载库

    来新公司半年多,最近一直在参与 Andorid 团队的架构升级工作.最近在图片选择库中使用了 paging 作为分页加载框架.顺便阅读了一下paging的源码.在这里记录一下. 初次接除 paging ...

最新文章

  1. 3天拆解数据分析全流程!
  2. MySQL中,当 update 修改数据与原数据相同时会再次执行吗?
  3. Spring-JDK Timer 以及在Spring(4.0以下)中使用JDK Timer
  4. 《Unity虚拟现实开发实战》——第1章,第1.8节小结
  5. GDCM:gdcm::SOPClassUIDToIOD的测试程序
  6. SimpleXMLRPC_python xmlrpclib SimpleXMLRPCServer 模块
  7. 信息学奥赛一本通(1402:Vigenère密码)
  8. 最近想学习一下编译原理,做一个编程规范的检测工具
  9. 有关Visual Studio Code的说明
  10. php获取对象属性值
  11. 冰汽朋克侦查机器人_冰汽时代生病机制是什么 寒霜朋克所有机制漏洞一览
  12. java Session缓存
  13. 2011 年上半年软考5 月 信息系统项目管理师上午试题参考答案
  14. Java8新特性之双冒号(::)
  15. 大猫谈JNCIE实验考试备战
  16. ML机器学习基础的编程技巧:
  17. 7-1 查找书籍 (20 分)给定n本书的名称和定价,本题要求编写程序,查找并输出其中定价最高和最低的书的名称和定价。输入格式:输入第一行给出正整数n(<10),随后给出n本书的信息
  18. 远控免杀专题(9)-Avet免杀(VT免杀率14/71)
  19. 核电站问题 解题报告
  20. Web全栈~04.css入门

热门文章

  1. 5类6类7类网线对比_5类 6类 7类网线有没有什么区别
  2. 4 security management strategies for data center consolidation
  3. 知识点总结之学习方式
  4. C语言学习:一个函数可以有几个返回值?
  5. 微信小程序加载图片优化
  6. VS2017使用Visual Leak Detector
  7. 苹果公司是如何“驻厂“管理供应商的
  8. vue的h函数_vue 中的h函数
  9. 浅谈两点分布,二项分布,伽马分布,指数分布,泊松分布,卡方分布,t分布,F分布,均匀分布,正态分布,β分布,狄利克雷分布--概率分布家族的伦理关系
  10. 扫二维码登陆微信 统计微信男女比例并绘图