GridView在ScrollView中实现在家更多
这个本身会有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中实现在家更多的更多相关文章
- ScrollView中嵌套GridView,ListView只显示一行的解决办法
转载:http://blog.csdn.net/luohai859/article/details/39347583 关于为什么只显示一行,个人理解是:如果单独使用GridView和ListView, ...
- ScrollView中嵌入ListView,GridView冲突的解决(让ListView全显示出来)
ScrollView中嵌入原生ListView或GridView,会出现ListView,GridView显示不全的问题. 解决方法:重新构造一个ListView或GridView,重写OnMeasu ...
- 在ScrollView中嵌入GridView
做android程序开发的都知道,不能在一个拥有Scrollbar的组件中嵌入另一个拥有Scrollbar的组件,因为这不科学,会混淆滑动事件,导致只显示一到两行数据.那么就换一种思路,首先让子控件的 ...
- ScrollView中嵌套GridView,Listview的办法
按照android的标准,ScrollView中是不能嵌套具有滑动特性的View的,但是有时如果设计真的有这样做的需要,或者为了更方便简单的实现外观(比如在外在的大布局需要有滑动的特性,并且内部有类似 ...
- Android学习之——如何将GridView内嵌在ScrollView中
最近在做一个项目,有一个需求是在ScrollView中内嵌一个GridView. 刚开始,我是以为能直接内嵌在里面: <ScrollView android:layout_width=" ...
- 解决在ScrollView中套用ListView显示不正常
最近在设计Android程序时,因为需要在ScrollView中添加一个ListView列表来显示一些信息.刚开始并没有想太多,但添加进去后才发现ListView不论怎样定义都只能显示一行,显示效果很 ...
- GridView 和ListView中自适应高度
android中GridView 和ListView放在scrollView中时会默认的只有一行高这时就要我们自己计算出它的高度啦 首先是listview的 //动态设置listview的高度 pu ...
- GridView模版列中设置
在GridView模版列中设置如下<asp:TemplateField HeaderText="删除"> <ItemTemplate> ...
- ScrollView中嵌套recycleView 出现的不显示,显示不全,终极解决方案
最近公司项目中用到了ScrollView去嵌套recycleView, 最开始我天真的把recycleView直接放入scrollView中,结果可想而知,什么都不显示,瞬间懵逼,我心想应该是和嵌套L ...
随机推荐
- ssh 登录
一.ssh登录过程 在实际开发中,经常使用ssh进行远程登录.ssh 登录到远程主机的过程包括: 版本号协商 密钥和算法协商 认证 交互 1.1 版本号协商阶段 (1) 服务端打开22端口(也可以为了 ...
- `UnityEditor.EditorUtility' does not contain a definition for `GetMiniThumbnail'
I got the following errors with Untiy 4.0f7error CS0117: `UnityEditor.EditorUtility' does not contai ...
- 关于如何使用Identity的文献
有几篇文件,深入浅出地讲解了如何一步一步的使用Identity,感觉十分有用,留下链接,备查. 1. Configuring Db Connection and Code-First Migratio ...
- .net 导出Excel功能
将DataSet对象导出成Excel文档 一.不带格式控制 void btnExport_Click(object sender, EventArgs e) { IList<string> ...
- 电子爱好者DIY篇
2016/7/15 电子爱好者DIY篇 一年和之前就想到了一些感悟,现在有些模糊的清晰起来了,但还是不够清晰,故写下来做个日志. 结论 首先把结论放在前面.目前随着电子集成电路的发展,电子DIY越来越 ...
- BIOS MCSDK 2.0 学习笔记(二)————使用Platform Library创建工程
[TOC] Platform Library提供了一组适用于开发板的API函数.我们可以使用它来快速入手开发板. 1.启动CCS,建立一个空的工程 2.添加include路径 "C:\Pro ...
- DataTable筛选出现异常
异常详细信息: System.ArgumentException: 在 Range 对象中,Min (37)必须小于或等于 max (-1). 解决方法:转化字段类型为int 再次出现问题:HH> ...
- jq中数组应用的错误
js中数组可以这样使用: <ul id="ul"> <li value="1">s</li> <li>f< ...
- css中vw,vh单位对于UC的兼容性问题
vw,vh单位在移动端浏览器不兼容,在网上找半天也没找到什么官方的解决方法:我就试了一下在使用到vh的单位之前添加一个用px定义的样式: 如: 当浏览器不是别100vw单位的时候 就会赋给px单位的样 ...
- Sphinx Search 学习 (一)
参考资料一:(中文)http://www.coreseek.cn/docs/coreseek_3.2-sphinx_0.9.9.html (官方)http://sphinxsearch.com/doc ...