Android PullToRefresh使用详解(五)--下拉刷新的ScrollView

本文详细介绍了如何在Android中实现PullToRefreshScrollView的下拉刷新功能,包括XML布局和JAVA代码实现。提供了具体步骤和代码示例,帮助开发者解决ScrollView下拉刷新问题。
摘要由CSDN通过智能技术生成

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.csdn.net/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

转自:http://blog.csdn.net/harvic880925/article/details/24722657

前言:时隔三月,再次用到PullToRefresh,但这次与上次不同,用到的是ScrollView的下拉刷新,网上资料甚少,唯有看源码,还好难度不大,一下午时间,攻克难题,分享给大家。

 以往相关文章

与本篇相关的只有第一篇的实例加载过程,其它内容都是针对ListView的下拉刷新讲解的。

PullToRefresh使用详解(四)--利用回调函数实现到底加载

PullToRefresh使用详解(三)--实现异步加载的下拉刷新列表

PullToRefresh使用详解(二)---重写BaseAdapter实现复杂XML下拉刷新

 《PullToRefresh使用详解(一)--构建下拉刷新的listView

 

 本篇效果图:

             下拉前                                               下拉中                                       下拉后

      

 效果讲解:

1、本例仅讲解上拉加载,对于其它加载内容,参考pullToRefresh源码,在PullToRefreshListActivity.java中写的很详细;

2、上拉加载前,有一个XML布局,下拉刷新后,添加一个与原有布局完全相同的动态布局,只是TextView的内容不一样了而已。

 一、下拉前

 1、导入Library库,至于导入Library库的过程,参考《PullToRefresh使用详解(一)--构建下拉刷新的listView》。

 2、XML构建:

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  2.     xmlns:tools="http://schemas.android.com/tools"  
  3.     android:layout_width="match_parent"  
  4.     android:layout_height="match_parent"  
  5.     android:orientation="vertical"  
  6.     tools:context=".MainActivity" >  
  7.   
  8.     <!-- The PullToRefreshScrollView replaces a standard PullToRefreshScrollView widget. -->  
  9.   
  10.     <com.handmark.pulltorefresh.library.PullToRefreshScrollView  
  11.         xmlns:ptr="http://schemas.android.com/apk/res-auto"  
  12.         android:id="@+id/pull_refresh_scrollview"  
  13.         android:layout_width="fill_parent"  
  14.         android:layout_height="fill_parent"  
  15.         ptr:ptrAnimationStyle="flip"  
  16.         ptr:ptrMode="both" >  
  17.   
  18.         <LinearLayout  
  19.             android:id="@+id/sub_root_lin"  
  20.             android:layout_width="fill_parent"  
  21.             android:layout_height="wrap_content"  
  22.             android:orientation="vertical" >  
  23.   
  24.             <!-- 动态创建布局开始 -->  
  25.             <LinearLayout  
  26.                 android:layout_width="fill_parent"  
  27.                 android:layout_height="wrap_content"  
  28.                 android:orientation="vertical" >  
  29.   
  30.                 <RelativeLayout  
  31.                     android:layout_width="fill_parent"  
  32.                     android:layout_height="wrap_content" >  
  33.   
  34.                     <ImageView  
  35.                         android:layout_wid
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值