这个本身会有bug  应该在滑动监听中作出判断的

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="@+id/s"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="false"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/love"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#fffccc"
android:text="caini xihuan " />
<com.maoyudun.alimamaproject.widget.MyGridView
android:id="@+id/fourth_GridView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f4f5f9"
android:horizontalSpacing="10px"
android:numColumns="2"
android:verticalSpacing="10px" />
<LinearLayout
android:id="@+id/loadmore"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:visibility="gone">
<ProgressBar
android:id="@+id/pb_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:indeterminateDrawable="@drawable/custom_progress" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="5dp"
android:text="正在加载..."
android:textColor="@android:color/black"
android:textSize="20dp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
解决显示不全的问题自定义的GridView
public class MyGridView extends GridView
{
public MyGridView(Context context) {
super(context);
}
public MyGridView(Context context, AttributeSet attrs) {
super(context, attrs);
} public MyGridView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
} @Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
}
定义接口监听什么时候显示最后一条数据
public interface LoadMoreGridViewListener {
void loadMore(int position);
}
在adapter中调用接口回传数据
LoadMoreGridViewListener loadmore;
public void onLoadMoreListener(LoadMoreGridViewListener load){
loadmore=load;
}
/**
* 判断滑动的位置
*/
if(position==mDatas.size()-1){
loadmore.loadMore(position);
}
在new adapater使用
void loadMore(int position);接口方法获取最后一个  
adapter.onLoadMoreListener(new LoadMoreGridViewListener() {
@Override
public void loadMore(int position) {
loadmore.animate().translationY(0).setDuration(300).setInterpolator(new AccelerateDecelerateInterpolator())
.setListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animation) {
loadmore.setVisibility(View.VISIBLE);
handler.sendEmptyMessageDelayed(1,5000); } @Override
public void onAnimationEnd(Animator animation) { } @Override
public void onAnimationCancel(Animator animation) { } @Override
public void onAnimationRepeat(Animator animation) { }
});
}
});
隐藏加载更多的时候直接GONE

GridView在ScrollView中实现在家更多的更多相关文章

  1. ScrollView中嵌套GridView,ListView只显示一行的解决办法

    转载:http://blog.csdn.net/luohai859/article/details/39347583 关于为什么只显示一行,个人理解是:如果单独使用GridView和ListView, ...

  2. ScrollView中嵌入ListView,GridView冲突的解决(让ListView全显示出来)

    ScrollView中嵌入原生ListView或GridView,会出现ListView,GridView显示不全的问题. 解决方法:重新构造一个ListView或GridView,重写OnMeasu ...

  3. 在ScrollView中嵌入GridView

    做android程序开发的都知道,不能在一个拥有Scrollbar的组件中嵌入另一个拥有Scrollbar的组件,因为这不科学,会混淆滑动事件,导致只显示一到两行数据.那么就换一种思路,首先让子控件的 ...

  4. ScrollView中嵌套GridView,Listview的办法

    按照android的标准,ScrollView中是不能嵌套具有滑动特性的View的,但是有时如果设计真的有这样做的需要,或者为了更方便简单的实现外观(比如在外在的大布局需要有滑动的特性,并且内部有类似 ...

  5. Android学习之——如何将GridView内嵌在ScrollView中

    最近在做一个项目,有一个需求是在ScrollView中内嵌一个GridView. 刚开始,我是以为能直接内嵌在里面: <ScrollView android:layout_width=" ...

  6. 解决在ScrollView中套用ListView显示不正常

    最近在设计Android程序时,因为需要在ScrollView中添加一个ListView列表来显示一些信息.刚开始并没有想太多,但添加进去后才发现ListView不论怎样定义都只能显示一行,显示效果很 ...

  7. GridView 和ListView中自适应高度

    android中GridView  和ListView放在scrollView中时会默认的只有一行高这时就要我们自己计算出它的高度啦 首先是listview的 //动态设置listview的高度 pu ...

  8. GridView模版列中设置

    在GridView模版列中设置如下<asp:TemplateField HeaderText="删除">    <ItemTemplate>         ...

  9. ScrollView中嵌套recycleView 出现的不显示,显示不全,终极解决方案

    最近公司项目中用到了ScrollView去嵌套recycleView, 最开始我天真的把recycleView直接放入scrollView中,结果可想而知,什么都不显示,瞬间懵逼,我心想应该是和嵌套L ...

随机推荐

  1. SSIS之-DTS对象&事件

    1.Dts 是类 Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptObjectModel 类的一个实例,Dts 对象有 7 个属性和一个方法,以下是DTS ...

  2. CIDR风格

    CIDR地址中包含标准的32位IP地址和有关网络前缀位数的信息. eg: 地址:192.168.10.0/24,其中/24标示前面地址中的前24位代表网络部分,其余代表主机部分. 11000000 1 ...

  3. Synchronized快

    /* JAVA对于多线程的安全问题提供了专业的解决方式 就是同步代码块 synchronized(对象)//这个对象可以为任意对象 { 需要被同步的代码 } 对象如同锁,持有锁的线程可以在同步中执行 ...

  4. Discuz! X3.1直接进入云平台列表的方法

    Discuz! X3.1已经改版,后台不能直接进云平台列表,不方便操作,操作云平台服务时,大家可以这样操作: 1.登录后台:2.访问域名进入云平台列表http://你域名/admin.php?fram ...

  5. mybatis 对于基本类型数据传值的问题

    最近在开发的时候,遇到一个小问题: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter fo ...

  6. bean生命周期

    一.Bean的定义Spring通常通过配置文件定义Bean.如:xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:s ...

  7. Python 修饰符

    def hello(fn):    def wrapper():        print "hello"        fn()        print "goodb ...

  8. 深入浅出Mybatis系列(十)---SQL执行流程分析(源码篇)

    最近太忙了,一直没时间继续更新博客,今天忙里偷闲继续我的Mybatis学习之旅.在前九篇中,介绍了mybatis的配置以及使用, 那么本篇将走进mybatis的源码,分析mybatis 的执行流程, ...

  9. iOS:使用代理模式监听开关状态改变事件

    记一次解决跨控制器监听开关状态改变的尝试. 为了统一设置UITableViewCell里的内容,自定义了UITableViewCell类的一个基类,命名为SettingCell.SettingCell ...

  10. 罗永浩Vs王自如:浮躁的世界该如何降温?!

    这段时间智能手机业界有一件事情炒得纷纷扬扬,可谓是波澜起伏,想必大家都多少略有耳闻.昨天中午在群里看到“罗永浩舌战王自如视频”分享,就有些‘凑热闹’的好奇点开看看.一开场的几分钟正如老罗所说的那样:两 ...