先上效果图:

下面详细说说这个页面是怎么做出来的:

1、这个页面最下方可以看到一个TAB页签,分别是“主页”、“提及”等等,这个是一个在底部的TAB分页样式,在上一篇博客中已经介绍了

2、这个页面就是“主页”这个子页面,是嵌入到上面说的TAB布局中的。由3个部分组成,分别是最上面的状态栏(包含2个按钮,和一个文本区)、中间的列表、最下方的“更多”按钮(当更多按钮点击时,会加载更多数据,并且出现LOADING提示)

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="fill_parent" android:layout_height="fill_parent">
  4. <LinearLayout android:background="#ffffffff"
  5. android:layout_width="fill_parent" android:layout_height="fill_parent"
  6. android:orientation="vertical" />
  7. <include android:id="@+id/head_line" layout="@layout/head_line"
  8. android:layout_width="fill_parent" android:layout_height="wrap_content" />
  9. <ListView android:cacheColorHint="#00000000" android:id="@id/android:list"
  10. android:layout_width="fill_parent" android:fastScrollEnabled="false"
  11. android:layout_height="wrap_content" android:paddingTop="45.0dip"
  12. android:fadingEdge="none" android:paddingBottom="50.0dip"
  13. android:divider="@drawable/list_divider" android:clipToPadding="false" />
  14. </FrameLayout>

上面这段代码,就生成了列表,和顶部的状态栏。顶部的状态栏是通过<include>标签引入的

  1. <RelativeLayout android:background="@drawable/header"
  2. android:layout_width="fill_parent" android:layout_height="wrap_content"
  3. xmlns:android="http://schemas.android.com/apk/res/android">
  4. <Button android:id="@+id/top_btn_left" android:textColor="@color/button_text_selector"
  5. android:background="@drawable/top_refresh_selector"
  6. android:layout_width="wrap_content" android:layout_height="wrap_content"
  7. android:layout_marginLeft="12.0dip" android:layout_alignParentLeft="true"
  8. android:layout_centerVertical="true" />
  9. <Button android:id="@+id/top_btn_right" android:textColor="@color/button_text_selector"
  10. android:background="@drawable/top_edit_selector" android:layout_width="wrap_content"
  11. android:layout_height="wrap_content" android:layout_marginRight="12.0dip"
  12. android:layout_alignParentRight="true" android:layout_centerVertical="true" />
  13. <TextView android:id="@+id/top_title" android:textSize="22.0sp"
  14. android:textColor="@color/head_line_text" android:ellipsize="middle"
  15. android:gravity="center_horizontal" android:layout_width="wrap_content"
  16. android:layout_height="wrap_content" android:text="@string/user_name"
  17. android:singleLine="true" android:layout_toLeftOf="@id/top_btn_right"
  18. android:layout_toRightOf="@id/top_btn_left"
  19. android:layout_centerInParent="true"
  20. android:layout_alignWithParentIfMissing="true" />
  21. </RelativeLayout>

是一个最简单的横向排列布局,就不用多介绍了

3、然后是这个FooterView是怎么添加进来的,看代码

  1. @Override
  2. protected void onCreate(Bundle savedInstanceState) {
  3. super.onCreate(savedInstanceState);
  4. setContentView(R.layout.home);
  5. setUpViews();// 设置视图
  6. setUpListeners();// 设置侦听器
  7. fillInitData();// 填充初始化数据
  8. }
  9. /**
  10. * 设置视图
  11. */
  12. private void setUpViews() {
  13. listView = getListView();// 得到ListView
  14. listFooter = (LinearLayout) LayoutInflater.from(this).inflate(
  15. R.layout.list_footer, null);
  16. listView.addFooterView(listFooter);// 添加FooterView
  17. more = (TextView) findViewById(R.id.more);
  18. loading = (LinearLayout) findViewById(R.id.loading);
  19. }

通过ListView.addFooterView()方法,来给列表添加一个FooterView,而这个FooterView,也是来自一个layout xml

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <LinearLayout android:layout_width="fill_parent"
  3. android:layout_height="wrap_content" android:minHeight="?android:listPreferredItemHeight"
  4. xmlns:android="http://schemas.android.com/apk/res/android">
  5. <TextView android:textSize="16.0sp" android:textColor="#ff545454"
  6. android:gravity="center" android:id="@+id/more" android:layout_width="fill_parent"
  7. android:layout_height="fill_parent" android:text="@string/more" />
  8. <LinearLayout android:gravity="center"
  9. android:layout_gravity="center" android:orientation="horizontal"
  10. android:id="@+id/loading" android:layout_width="fill_parent"
  11. android:layout_height="fill_parent">
  12. <ProgressBar android:layout_gravity="center_vertical"
  13. android:id="@+id/footprogress" android:layout_width="wrap_content"
  14. android:layout_height="wrap_content" android:indeterminateBehavior="repeat"
  15. style="?android:progressBarStyleSmallInverse" />
  16. <TextView android:textColor="#ff000000" android:gravity="left|center"
  17. android:padding="3.0px" android:layout_width="wrap_content"
  18. android:layout_height="wrap_content" android:text="@string/loading" />
  19. </LinearLayout>
  20. </LinearLayout>

这个FooterView包含一个“更多”的文本框,和一个“读取中”文本框。这里我没弄明白的是,为什么一开始默认只会显示“更多”,读取栏不会显示出来,需要

  1. more.setOnClickListener(new OnClickListener() {
  2. @Override
  3. public void onClick(View v) {
  4. more.setVisibility(View.GONE);
  5. loading.setVisibility(View.VISIBLE);
  6. }
  7. });

这样做,才能让“更多”按钮消失,显示出“读取中”,希望知道的朋友给我讲解一下。

通过上面的代码,就可以做出效果图里的页面了。

顶部有一排按钮,最底下还有FooterView的ListView页面的更多相关文章

  1. 添加“返回顶部”小图标按钮的JS(JavaScript)代码详解

    如何给自己的网站添加方便快捷的"返回顶部"小图标按钮呢?如下图: JS源代码: /** * JavaScript脚本实现回到页面顶部示例 * @param acceleration ...

  2. Android 一排按钮居中显示

    将一排按钮放在LinearLayout中,设置LinearLayout的Android gravity属性为center_vertical(垂直居中)

  3. js点击button按钮跳转到另一个新页面

    点击按钮怎么跳转到另外一个页面呢?我们在网站制作中可能是需要的,因为有时我们需要做这样的效果,尤其是将按钮做成一个图片,而点击图片要跳转到新的页面时,怎么做到呢? 这样的效果可以:onclick=&q ...

  4. PHP——0128练习相关2——js点击button按钮跳转到另一个新页面

    js点击button按钮跳转到另一个新页面 投稿:whsnow 字体:[增加 减小] 类型:转载 时间:2014-10-10我要评论 点击按钮怎么跳转到另外一个页面呢?点击图片要跳转到新的页面时,怎么 ...

  5. 纯CSS3实现的顶部社会化分享按钮

    今天要分享一款纯CSS3实现的社会化分享按钮,它放置在网页的顶部,你可以选择将它固定在网页顶部,这样对用户分享内容就十分方便.这些社会化分享按钮的图标文件来自google和bootstrap的字体文件 ...

  6. js或jquery实现点击某个按钮或元素显示div,点击页面其他任何地方隐藏div

    点击某个元素显示div,点击页面其他任何地方隐藏div,可用javascript和jquery两种方法实现: 一:javascript实现方法技巧<script>//定义stopPropa ...

  7. jqgrid如何在一个页面点击按钮后,传递参数到新页面

    利用 Content/Scripts/dw-framework.js 中的AddTableMenu属性 <div class="Task" style="backg ...

  8. HTML:一个form表单有两个按钮,分别提交到不同的页面

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  9. ListCtrl使用指南

    http://blog.csdn.net/bqw2008/article/details/2047489 Windows ListCtrl使用技巧1. ListCtrl 风格       LVS_IC ...

随机推荐

  1. python基础之序列化 time random os

    序列化与反序列化 json  pickle 1.什么是序列化与反序列化? 序列化就是将内存中的数据结构转成一种中间格式储存到硬盘或者基于网络传输 反序列化是网络,硬盘将被序列化的对象重新读到内存 2. ...

  2. pymysql与mysql各功能

    pymysql # 增删改操作 import pymysql client=pymysql.connect( host='127.0.0.1', port=3306, user='root', pas ...

  3. BUG:upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected

    更换Apache扑向Nginx,刚搭建完WNMP,nginx能访问php页面 但是访问现有开发项目报错 [error] 4112#3724: *9 upstream timed out (10060: ...

  4. sqlserver 脚本 多条记录遍历

    临时表方式实现多条记录遍历 declare @oper_cart_item_id bigint; declare @oper_cart_id bigint; declare @the_last_cha ...

  5. 让你的WPF程序在Win7下呈现Win8风格主题

    今天在Win8下使用了一个我之前写的一个WPF程序的时候,发现现在也支持Win8效果了(记得以前的.net 4.0的版本是不支持的).由于WPF的控件是自绘的,并不受系统主题所控制,也就是说.net ...

  6. llvm之旅第一站 - 编译及简单使用 LLVM 图解

    http://www.nagain.com/activity/article/4/ http://blog.csdn.net/snsn1984/article/details/8593380

  7. rdlc报表集锦

    rdlc报表动态生成实例 http://blog.csdn.net/fwj380891124/article/details/8803844  rdlc报表动态生成公共类 http://blog.cs ...

  8. 三大UML建模工具Visio、Rational Rose、PowerDesign

    UML建模工具Visio .Rational Rose.PowerDesign的比较 应用最广的由两种种1. Rational Rose,它是ibm的 .2.Microsoft的 Microsoft ...

  9. java ArrayList源码分析(转载)

    1.ArrayList是一个相对来说比较简单的数据结构,最重要的一点就是它的自动扩容,可以认为就是我们常说的“动态数组”. 来看一段简单的代码: 12345 ArrayList<String&g ...

  10. SQL Server CPU时间和占用时间及优化

    如何测试sql语句执行时间 在MSSQL Server中通过查看SQL语句执行所用的时间,来衡量SQL语句的性能. set statistics profile on set statistics i ...