安卓开发 phoenix下拉刷新+taurus下拉刷新
来源:互联网 发布:网络架构 知识 编辑:程序博客网 时间:2024/06/03 22:41
phoenix 刷新 依赖:
//phoenix下拉加载 compile 'com.yalantis:phoenix:1.2.3'
xml使用依赖控件包裹Listview:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.yalantis.phoenix.PullToRefreshView android:id="@+id/PullToRefreshView" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/ListView" android:layout_width="match_parent" android:layout_height="match_parent" /> </com.yalantis.phoenix.PullToRefreshView></LinearLayout>
主页面:
public class MainActivity extends AppCompatActivity { @Bind(R.id.ListView) android.widget.ListView ListView; @Bind(R.id.phoenix) PullToRefreshView phoenix; List<String> strings = new ArrayList<>(); int i = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ButterKnife.bind(this); strings.add("下拉刷新"); ListView.setAdapter(new ArrayAdapter<>(MainActivity.this, R.layout.support_simple_spinner_dropdown_item, strings)); phoenix.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { @Override public void onRefresh() { phoenix.postDelayed(new Runnable() { @Override public void run() { initData(); //线程2秒,false表示刷新完成 phoenix.setRefreshing(false); startActivity(new Intent(MainActivity.this, TaurusActivity.class)); } }, 2000); } }); } private void initData() { for (; i <= 5; i++) { strings.add("第" + i + "个"); } }}
实现截图:
刷新出来的动画挺好看的~
-----------------------------------------------------------华丽的分割线------------------------------------------------------------------
taurus下拉刷新 依赖:
//taurus下拉刷新 compile 'org.knowm.xchange:xchange-taurus:4.2.1'
依赖需要添加:(在Android()中)
allprojects { repositories { jcenter() maven { url "https://jitpack.io" } } }
xml使用依赖控件包裹Listview:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.yalantis.taurus.PullToRefreshView android:id="@+id/taurus" android:layout_width="match_parent" android:layout_height="match_parent"> <ListView android:id="@+id/ListView" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@android:color/white" /> </com.yalantis.taurus.PullToRefreshView></LinearLayout>
TaurusActivity页面代码:(几乎没差别)
public class TaurusActivity extends AppCompatActivity { @Bind(R.id.ListView) android.widget.ListView ListView; @Bind(R.id.taurus) PullToRefreshView taurus; List<String> strings = new ArrayList<>(); int i = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_taurus); ButterKnife.bind(this); strings.add("下拉刷新"); ListView.setAdapter(new ArrayAdapter<>(TaurusActivity.this, R.layout.support_simple_spinner_dropdown_item, strings)); taurus.setOnRefreshListener(new PullToRefreshView.OnRefreshListener() { @Override public void onRefresh() { taurus.postDelayed(new Runnable() { @Override public void run() { initData(); //线程2秒,false表示刷新完成 taurus.setRefreshing(false); } }, 2000); } }); } private void initData() { for (; i <= 5; i++) { strings.add("第" + i + "个"); } }}
实现截图:
Demo地址:https://github.com/Small-code-monkey/DropdownrefreshDemo/tree/master
阅读全文
0 0
- 安卓开发 phoenix下拉刷新+taurus下拉刷新
- 下拉刷新Phoenix分析
- 安卓下拉刷新
- 安卓下拉刷新解决方案
- 安卓下拉刷新,pulltorefresh的使用
- 安卓下拉刷新开源库对比
- 安卓日记——下拉刷新
- 安卓下拉刷新开源库对比
- 安卓下拉刷新开源库对比
- 实现安卓下拉刷新自动返回
- 安卓下拉刷新开源库对比
- iOS开发 ----- 下拉刷新
- Android开发--下拉刷新
- 下拉刷新
- 下拉刷新
- 下拉刷新
- 下拉刷新
- 下拉刷新
- 接受拒绝算法-rejection sampling
- JS之数组删除/添加项目方法splice
- [区块链]Hyperledger Fabric源代码(基于v1.0 beta版本)阅读之乐扣老师解读系列 (一)Fabric简介
- storm配置文件详解
- Unity 切换游戏场景时屏幕淡入淡出效果 第二版
- 安卓开发 phoenix下拉刷新+taurus下拉刷新
- 读 《Python机器学习及实践 》感受
- 商品加入购物车抛物线下坠的动画
- ajax技巧
- 算法题目-二叉树的重建
- 没事讲讲二叉树
- 基于视觉交互的行为识别
- xinetd使用指南
- C# 面向对象与常用API的学习