PullToRefreshGridView
来源:互联网 发布:房屋外观设计简单软件 编辑:程序博客网 时间:2024/06/14 17:48
控件: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博客)
- saltstack的常用操作(三) 命令与模块的执行
- Coordinator-wf-mr
- 获取样式的时候用offsetWidth 这类有Bug 要用 obj.currentStyle.width 或getComputedStyle(obj,null).width
- codeforce Maximum of Maximums of Minimums(区间划分 求区间最小值最大值问题)
- error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http:/
- PullToRefreshGridView
- 创建线程继承Thread和实现Runnable接口
- 链表的简单操作
- [HDU]4507 恨7不成妻 数位Dp好题
- BZOJ 1596: [Usaco2008 Jan]电话网络 树形dp||贪心
- Windows 下 Apache2 Django配置(针对找不到mod_wsgi.so)
- NetDataUtil_获取网络数据的工具类
- 浅论3大方法求单源最短路以及2大方法求最小生成树
- 记忆网络之Hierarchical Memory Networks(架构分层)