PullToRefreshGridView
来源:互联网 发布:连接网络的软件 编辑:程序博客网 时间:2024/06/15 00:35
//控件:gridView
<com.handmark.pulltorefresh.library.PullToRefreshGridView android:id="@+id/plv" xmlns:ptr="http://schemas.android.com/apk/res-auto" android:layout_height="match_parent" android:layout_width="match_parent" ptr:ptrDrawable="@drawable/default_ptr_flip" ptr:ptrAnimationStyle="flip" android:numColumns="2" ptr:ptrHeaderBackground="#383838" ptr:ptrHeaderTextColor="#FFFFFF" ></com.handmark.pulltorefresh.library.PullToRefreshGridView>
private View view;private PullToRefreshGridView pulllist;int pid=1;BaseGrid base;List<MyDeteBean.ResultsBean> results=new ArrayList<>();private ILoadingLayout loadingLayoutProxy;@Nullable@Overridepublic View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { view = inflater.inflate(R.layout.fragment2_layout,container,false); pulllist = view.findViewById(R.id.plv); return view;}@Overridepublic void onActivityCreated(@Nullable Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); sta(); pulllist.setMode(PullToRefreshBase.Mode.BOTH); loadingLayoutProxy = pulllist.getLoadingLayoutProxy(true, false); loadingLayoutProxy.setPullLabel("下拉刷新"); loadingLayoutProxy.setRefreshingLabel("正在拉"); loadingLayoutProxy.setReleaseLabel("放开刷新"); ILoadingLayout load = pulllist.getLoadingLayoutProxy(false, true); load.setPullLabel("上拉刷新"); load.setRefreshingLabel("正在加载"); load.setReleaseLabel("放开刷新"); pulllist.setOnRefreshListener(new PullToRefreshBase.OnRefreshListener2<GridView>() { @Override public void onPullDownToRefresh(PullToRefreshBase<GridView> refreshView) { //下拉刷新....请求第一页的数据,清空之前的数据,然后再添加设置适配器 xrefalsh(); } @Override public void onPullUpToRefresh(PullToRefreshBase<GridView> refreshView) { //上拉刷新/加载...加载的时候页数++ pid++; sta(); } });}public void sta(){ String path="http://gank.io/api/data/Android/10/"+pid; NetWorkUrl.newUrl(getActivity(), path, new NetPort() { @Override public void port(String json) { Gson gson =new Gson(); MyDeteBean bean = gson.fromJson(json, MyDeteBean.class); results.addAll(bean.getResults()); if(base==null){ base=new BaseGrid(getActivity(),results); pulllist.setAdapter(base); }else{ base.notifyDataSetChanged(); } pulllist.onRefreshComplete(); } });}public void xrefalsh(){ pid--; String path="http://gank.io/api/data/Android/10/"+pid; NetWorkUrl.newUrl(getActivity(), path, new NetPort() { @Override public void port(String json) { Gson gson =new Gson(); results.clear(); MyDeteBean bean = gson.fromJson(json, MyDeteBean.class); results.addAll(0,bean.getResults()); if(base==null){ base=new BaseGrid(getActivity(),results); pulllist.setAdapter(base); }else{ base.notifyDataSetChanged(); } pulllist.onRefreshComplete(); loadingLayoutProxy.setLastUpdatedLabel("上次刷新时间"+new SimpleDateFormat("HH:mm").format(new Date(System.currentTimeMillis()))+";"); } });}
阅读全文
0 0
- PullToRefreshGridView
- PullToRefreshGridView
- PullToRefreshGridView
- PullToRefreshGridView
- PullToRefreshGridView下拉刷新
- PullToRefreshGridView添加头部
- PullToRefreshGridView的使用
- pullToRefreshGridView里面不显示数据
- 上拉分页加载PullToRefreshGridView
- PullToRefreshGridView中xml的配置
- PullToRefreshGridView上拉刷新,下拉加载
- 开源插件 PullToRefresh: PullToRefreshListView / PullToRefreshGridView 实例详解
- PullToRefreshGridView添加头部, GridView添加头部head的PullToRefresh
- PullToRefreshGridView 带下拉刷新,上拉加载的GridView控件
- PullrefreshLibrary(PullToRefreshGridView)上拉刷新,下拉加载+异步AsyncTask(二)
- 抽屉布局+Fragment+TabLayout上导航栏+PullToRefreshListView+轮播图+PullToRefreshGridView
- 开源项目PullToRefresh详解(二)——PullToRefreshGridView
- PullToRefreshGridView改变下拉的文字(2015.8.19第一次使用csdn博客)
- matlab layout
- RDDs的特性
- 关于Ubuntu中Could not get lock /var/lib/dpkg/lock解决方案
- C/C++常用头文件汇总
- kivy 中 .kv 文件的使用
- PullToRefreshGridView
- Struts 2中<s:include>标签的用法
- 实习记录2 fs初看
- 网络连接的判断及网络类型的判断
- 【bzoj3450】Tyvj1952 Easy 期望dp
- Android中getDimension,getDimensionPixelOffset和getDimensionPixelSize 区别
- hdu1575(矩阵快速幂基础)
- 析构函数的一些特点
- caffe study(5) - AlexNet 之结构篇