这个本身会有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. 在重新生成解决方案时,出现的错误:无法将文件“obj\x86\Debug\*.exe”复制到“obj\Debug\*.exe”。文件正由另一进程使用,因此该进程无法访问此文件

    此例是VS2010的CS项目. 在重新生成解决方案时,出现的错误. 解决步骤:先关闭解决方案,再在项目文件下的bin\Debug\*.exe删除这类之前生成得.exe文件,再在VS2010下重新生成.

  2. gdb 常用内容

    gdb exegdb exe coregdb -p info m TAB ^関数の先頭 info b ^list the breakpoint set args -a test ^引数設定 show ...

  3. 关于unity碰撞检测器的用法

    今天已经是我第三次忘记了这两种碰撞检测的用法,混淆了.特意整理一下 首先把今天要解决涉及到的东西列出来 碰撞方法: public void OnTriggerEnter(Collider other) ...

  4. GbkToUtf8 Utf8ToGbk PackHttp

    void CFunc::GbkToUtf8(CString &strGBK) { , (LPCTSTR)strGBK, -, NULL, ); unsigned ]; memset(wszUt ...

  5. 破解YunFile下载间隔10分钟/下载等待30秒

    [破解10分钟间隔] 可以采用断网重连等方法重新获取IP地址,就不用再等十分钟了 [破解30秒等待] 收藏一个书签,书签地址如下 javascript:var downpage_link = docu ...

  6. [HTML/CSS] ul元素居中处理

    CSS: <style type="text/css"> #nav_sub_page { text-align: center; width: 80%; } #nav_ ...

  7. explain 执行计划详解

    id:id是一组数字,表示查询中执行select子句或操作表的顺序,如果id相同,则执行顺序从上至下,如果是子查询,id的序号会递增,id越大则优先级越高,越先会被执行. id列为null的就表是这是 ...

  8. opencv 基础语法

    1.关于图像:显示图象 //在指定窗口显示图像cvShowImage void cvShowImage( const char* name, const CvArr* image ); name:窗口 ...

  9. MICAPS二次开发一些功能调用

    1.调用地图并将micaps文件加载地图上 IFileBindingService fbs = ServiceLocator.Current.GetInstance< IFileBindingS ...

  10. OpenCV 学习

    #include <opencv2\opencv.hpp> #include <iostream> #include <opencv2\highgui\highgui.h ...