史上最最最炫酷动感的下拉刷新,只需要十秒钟就可以让你完成。

在我们处理很多很繁冗数据的时候,我们用到了listview去装载数据,但可显示的区域有限,这时候我们就需要用到我们的下拉刷新去加载更多的数据了。这个效果是仿制android5.0的效果在额外多了一个粘性效果动画,更加的酷了。


   下面 我们还是先来看 一下 项目的结构。

上面的是我们加入的工具类 那里的代码都是人家封装好的了 我们关键看 怎么用就好了,站在巨人的肩膀总是轻松的。我们看一下 怎么使用这个 刷新的 主类把

MainActivity
package jp.co.recruit_lifestyle.sample;

import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
import jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout;

public class MainActivity extends AppCompatActivity implements WaveSwipeRefreshLayout.OnRefreshListener {

  private ListView mListview;

  private WaveSwipeRefreshLayout mWaveSwipeRefreshLayout;

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    /**设置没有标题栏*/
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    //getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    //透明状态栏
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    //透明导航栏
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    setSampleData();
  }

  private void initView() {
    mWaveSwipeRefreshLayout = (WaveSwipeRefreshLayout) findViewById(R.id.main_swipe);
    //设置 下拉在转的圈圈的颜色            第一个颜色 是 第一圈带箭头的 第二个颜色是不带箭头的
    mWaveSwipeRefreshLayout.setColorSchemeColors(Color.CYAN, Color.RED);
    mWaveSwipeRefreshLayout.setOnRefreshListener(this);
    /**红色0x000000ff
     绿色0x0000ff00
     蓝色0x00ff0000
     黄色0x0000ffff
     青色0x00ffff00
     品红0x00ff00ff
     黑色0x00000000
     白色0x00ffffff
     灰色0x00808080
     草绿0x006bdec7
     紫色0x00c000c0*/
    //mWaveSwipeRefreshLayout.setWaveColor(0x0000ff00);
    //mWaveSwipeRefreshLayout.setBackgroundColor(0x00000000);

    //设置水滴落下的最大高度
    mWaveSwipeRefreshLayout.setMaxDropHeight(500);

    mListview = (ListView) findViewById(R.id.main_list);
  }

  private void setSampleData() {
    ArrayList<String> sampleArrayStr = new ArrayList<>();
    for (int i = 0; i < 60; i++) {
      sampleArrayStr.add("" );
    }
    ArrayAdapter<String> adapter = new ArrayAdapter<>(getApplicationContext(), android.R.layout.simple_list_item_1, sampleArrayStr);
    mListview.setAdapter(adapter);
  }

  private void refresh() {
    new Handler().postDelayed(new Runnable() {
      @Override
      public void run() {
        // 更新が終了したらインジケータ非表示
        mWaveSwipeRefreshLayout.setRefreshing(false);
      }
    }, 3000);
  }

  @Override
  protected void onResume() {
    mWaveSwipeRefreshLayout.setRefreshing(false);
    refresh();
    super.onResume();
  }

  @Override
  public void onRefresh() {
    refresh();
  }




}
在这个类里面 我们调用了刷新的类 设置了他一些属性,当然 我们通过
mWaveSwipeRefreshLayout.set****();你可以去设置更多你想要自己设置的东西了。
我们的布局也非常简单 就是 view+view +自定义的刷新类+listview的形式来实现的
代码:
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity"
    >

  <View
      android:layout_width="match_parent"
      android:layout_height="25dip"
      android:background="@color/primary_dark"
      />

  <RelativeLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:layout_weight="1"
      >

    <android.support.v7.widget.Toolbar
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:minHeight="?attr/actionBarSize"
        android:background="@color/primary"
        android:id="@+id/toolbar"
        />

    <View
        android:layout_width="match_parent"
        android:layout_height="5dp"
        android:background="@drawable/toolbar_dropshadow"
        android:layout_below="@+id/toolbar"
        />


    <jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/main_swipe"
        android:layout_below="@+id/toolbar"
        >

      <ListView
          android:id="@+id/main_list"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          />

    </jp.co.recruit_lifestyle.android.widget.WaveSwipeRefreshLayout>

  </RelativeLayout>

</LinearLayout>
还有图片资源 跟 颜色的配置之类的 大家 自行看我上传的demo 到 res 文件夹下查看。

通过人家封装好的工具类我们花一点时间就可以实现 跟别人与众不同的下拉控件了。

大家 有问题可以 进群:166120952 进行 讨论

下载地址:http://download.csdn.net/detail/ningzhouxu/9619348

现在上传的资源大部分都是 android studio 来进行编译的了。么么哒


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 6
    评论
Protection Options for 百度刷相关搜索-刷下拉列表框软件V1.0.exe -------------------------------------------------------------- Macros Information ------------------ VM Macros: 0 CodeReplace Macros: 0 ENCRYPT Macros: 0 CLEAR Macros: 0 CHECK_PROTECTION Macros: 0 CHECK_CODE_INTEGRITY Macros: 0 Protection Options ------------------ Anti-Debugger: Advanced Anti-Dumpers: ENABLED Entry Point Obfuscation: ENABLED Resource Encryption: ENABLED VMWare compatible: ENABLED API-Wrapping Level: Level 2 Anti-Patching: None Metamorph Security: ENABLED Memory Guard: ENABLED When Debugger Found: Display Message Application compression: ENABLED Resources compression: DISABLED SecureEngine compression: ENABLED Anti-File Monitor: ENABLED Anti-Registry Monitor: ENABLED Delphi/BCB form protection: ENABLED Ring-0 Protection: DISABLED Virtual Machine Settings ------------------------ Number of Virtual APIs wrapped: 0 API Virtualization Level: 1 Entry Point Virtualization: 0 instructions Multi Branch Technology: DISABLED Virtual Machine Processor: Mutable CISC processor Number of CPUs: 1 Opcode Type: Metamorphic - Level 2 Dynamic Opcode: 20% Dynamic Trial Settings -------------- Days Expiration: 1 Executions: 3 Runtime: 10 Clock Change: 1 hour Trial Extension: DISABLED With single file: extendkey.dat Registration Settings --------------------- Signature Level: 等级2 With Single file: regkey.dat Only Hardware locked keys: DISABLED Only Temporary keys: DISABLED Only runs when registered: DISABLED Clear Trial when registered: DISABLED Advanced Protection Options --------------------------- Encrypt Application: ENABLED DLL plugin: DISABLED Export Generators: ENABLED Keep Trial Running: DISABLED Hide from PE scanners: Standard .NET assemblies: ENABLED Active Context: DISABLED Custom Event: Add Manifest: Don't add manifest Launch Application: XBundler files -------------- No files to bundle

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值