顶部有一排按钮,最底下还有FooterView的ListView页面
先上效果图: 
下面详细说说这个页面是怎么做出来的:
1、这个页面最下方可以看到一个TAB页签,分别是“主页”、“提及”等等,这个是一个在底部的TAB分页样式,在上一篇博客中已经介绍了
2、这个页面就是“主页”这个子页面,是嵌入到上面说的TAB布局中的。由3个部分组成,分别是最上面的状态栏(包含2个按钮,和一个文本区)、中间的列表、最下方的“更多”按钮(当更多按钮点击时,会加载更多数据,并且出现LOADING提示)
- <?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:background="#ffffffff"
- android:layout_width="fill_parent" android:layout_height="fill_parent"
- android:orientation="vertical" />
- <include android:id="@+id/head_line" layout="@layout/head_line"
- android:layout_width="fill_parent" android:layout_height="wrap_content" />
- <ListView android:cacheColorHint="#00000000" android:id="@id/android:list"
- android:layout_width="fill_parent" android:fastScrollEnabled="false"
- android:layout_height="wrap_content" android:paddingTop="45.0dip"
- android:fadingEdge="none" android:paddingBottom="50.0dip"
- android:divider="@drawable/list_divider" android:clipToPadding="false" />
- </FrameLayout>
上面这段代码,就生成了列表,和顶部的状态栏。顶部的状态栏是通过<include>标签引入的
- <RelativeLayout android:background="@drawable/header"
- android:layout_width="fill_parent" android:layout_height="wrap_content"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <Button android:id="@+id/top_btn_left" android:textColor="@color/button_text_selector"
- android:background="@drawable/top_refresh_selector"
- android:layout_width="wrap_content" android:layout_height="wrap_content"
- android:layout_marginLeft="12.0dip" android:layout_alignParentLeft="true"
- android:layout_centerVertical="true" />
- <Button android:id="@+id/top_btn_right" android:textColor="@color/button_text_selector"
- android:background="@drawable/top_edit_selector" android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:layout_marginRight="12.0dip"
- android:layout_alignParentRight="true" android:layout_centerVertical="true" />
- <TextView android:id="@+id/top_title" android:textSize="22.0sp"
- android:textColor="@color/head_line_text" android:ellipsize="middle"
- android:gravity="center_horizontal" android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/user_name"
- android:singleLine="true" android:layout_toLeftOf="@id/top_btn_right"
- android:layout_toRightOf="@id/top_btn_left"
- android:layout_centerInParent="true"
- android:layout_alignWithParentIfMissing="true" />
- </RelativeLayout>
是一个最简单的横向排列布局,就不用多介绍了
3、然后是这个FooterView是怎么添加进来的,看代码
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.home);
- setUpViews();// 设置视图
- setUpListeners();// 设置侦听器
- fillInitData();// 填充初始化数据
- }
- /**
- * 设置视图
- */
- private void setUpViews() {
- listView = getListView();// 得到ListView
- listFooter = (LinearLayout) LayoutInflater.from(this).inflate(
- R.layout.list_footer, null);
- listView.addFooterView(listFooter);// 添加FooterView
- more = (TextView) findViewById(R.id.more);
- loading = (LinearLayout) findViewById(R.id.loading);
- }
通过ListView.addFooterView()方法,来给列表添加一个FooterView,而这个FooterView,也是来自一个layout xml
- <?xml version="1.0" encoding="UTF-8"?>
- <LinearLayout android:layout_width="fill_parent"
- android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeight"
- xmlns:android="http://schemas.android.com/apk/res/android">
- <TextView android:textSize="16.0sp" android:textColor="#ff545454"
- android:gravity="center" android:id="@+id/more" android:layout_width="fill_parent"
- android:layout_height="fill_parent" android:text="@string/more" />
- <LinearLayout android:gravity="center"
- android:layout_gravity="center" android:orientation="horizontal"
- android:id="@+id/loading" android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <ProgressBar android:layout_gravity="center_vertical"
- android:id="@+id/footprogress" android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:indeterminateBehavior="repeat"
- style="?android:progressBarStyleSmallInverse" />
- <TextView android:textColor="#ff000000" android:gravity="left|center"
- android:padding="3.0px" android:layout_width="wrap_content"
- android:layout_height="wrap_content" android:text="@string/loading" />
- </LinearLayout>
- </LinearLayout>
这个FooterView包含一个“更多”的文本框,和一个“读取中”文本框。这里我没弄明白的是,为什么一开始默认只会显示“更多”,读取栏不会显示出来,需要
- more.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- more.setVisibility(View.GONE);
- loading.setVisibility(View.VISIBLE);
- }
- });
这样做,才能让“更多”按钮消失,显示出“读取中”,希望知道的朋友给我讲解一下。
通过上面的代码,就可以做出效果图里的页面了。
顶部有一排按钮,最底下还有FooterView的ListView页面的更多相关文章
- 添加“返回顶部”小图标按钮的JS(JavaScript)代码详解
如何给自己的网站添加方便快捷的"返回顶部"小图标按钮呢?如下图: JS源代码: /** * JavaScript脚本实现回到页面顶部示例 * @param acceleration ...
- Android 一排按钮居中显示
将一排按钮放在LinearLayout中,设置LinearLayout的Android gravity属性为center_vertical(垂直居中)
- js点击button按钮跳转到另一个新页面
点击按钮怎么跳转到另外一个页面呢?我们在网站制作中可能是需要的,因为有时我们需要做这样的效果,尤其是将按钮做成一个图片,而点击图片要跳转到新的页面时,怎么做到呢? 这样的效果可以:onclick=&q ...
- PHP——0128练习相关2——js点击button按钮跳转到另一个新页面
js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...
- 纯CSS3实现的顶部社会化分享按钮
今天要分享一款纯CSS3实现的社会化分享按钮,它放置在网页的顶部,你可以选择将它固定在网页顶部,这样对用户分享内容就十分方便.这些社会化分享按钮的图标文件来自google和bootstrap的字体文件 ...
- js或jquery实现点击某个按钮或元素显示div,点击页面其他任何地方隐藏div
点击某个元素显示div,点击页面其他任何地方隐藏div,可用javascript和jquery两种方法实现: 一:javascript实现方法技巧<script>//定义stopPropa ...
- jqgrid如何在一个页面点击按钮后,传递参数到新页面
利用 Content/Scripts/dw-framework.js 中的AddTableMenu属性 <div class="Task" style="backg ...
- HTML:一个form表单有两个按钮,分别提交到不同的页面
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- ListCtrl使用指南
http://blog.csdn.net/bqw2008/article/details/2047489 Windows ListCtrl使用技巧1. ListCtrl 风格 LVS_IC ...
随机推荐
- 兼容IE8
由于IE8不支持HTML5,而它又是Win7的默认浏览器,我们即使讨厌它,在这几年却也拿它没办法. 最近做了个需要兼容IE8的项目,不可避免地用了HTML5+CSS3,甚至canvas和svg,做兼容 ...
- futer.get()(如果任务没执行完将等待)
/** * 获取异步任务的执行结果(如果任务没执行完将等待) */ V get() throws InterruptedException, ExecutionException; Future必要时 ...
- 三大UML建模工具Visio、Rational Rose、PowerDesign
UML建模工具Visio .Rational Rose.PowerDesign的比较 应用最广的由两种种1. Rational Rose,它是ibm的 .2.Microsoft的 Microsoft ...
- [Android Pro] 使用CursorLoader异步加载数据 from 3.0
Android 3.0引入了CursorLoader实现异步加载数据,为了避免同步查询数据库时阻塞UI线程的问题.在API 11之前可以通过下载支持库,来使之前的系统支持此功能,下载页面为 http: ...
- Android应用内使用新浪微博SDK发送微博(不调用微博客户端)
需求 手头的一个应用需要添加分享到新浪微博的功能,这个功能在现在的应用上是非常的普遍的了. 分享到新浪微博,其实就是发送一条特定内容的微博,所以需要用到新浪微博SDK了. 微博SDK SDK的下载地址 ...
- ExtJS初学笔记---Ext.Msg.alert无效果
最近开始学ExtJS,书上的第一个例子是: 1 2 3 Ext.onReady(function(){ Ext.Msg.alert('Hello.', 'Hello'); }); 这个是Ext ...
- Kafka的架构设计(目前翻译最好的一稿)
转自:http://www.oschina.net/translate/kafka-design 参与翻译(4人):fbm, 飞翔的猴子, Khiyuan, nesteaa 感谢这些同志们的辛勤工作, ...
- ArrayList源码深度解析
jdk:1.8 一.先看看ArrayList类的整体概述, ArraList是基于动态数组实现的一种线性列表,这种基于动态数组的好处就是索引比较快,时间复杂度为O(1):但是对数据修改比较慢,因为需要 ...
- 使用git-svn迁移SVN至GitLab
使用git-svn迁移SVN至GitLab 1.安装git和git-svn 后面的步骤中对git版本有一定要求,通过yum安装的git版本较低,这里进行编译安装 [root@DevTest ~]# y ...
- RESTful最佳实践
哲学 不要为了RESTful而RESTful 在能表达清楚的情况下,简单就是美 接口路径设计 接口设计原则 URI指向的是唯一的资源对象 示例: 指向ID为yanbo.ai的Account对象 GET ...