分享一下我老师大神的人工智能教程!零基础,通俗易懂!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构建:
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:context=".MainActivity" >
- <!-- The PullToRefreshScrollView replaces a standard PullToRefreshScrollView widget. -->
- <com.handmark.pulltorefresh.library.PullToRefreshScrollView
- xmlns:ptr="http://schemas.android.com/apk/res-auto"
- android:id="@+id/pull_refresh_scrollview"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- ptr:ptrAnimationStyle="flip"
- ptr:ptrMode="both" >
- <LinearLayout
- android:id="@+id/sub_root_lin"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
- <!-- 动态创建布局开始 -->
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
- <RelativeLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content" >
- <ImageView
- android:layout_wid