一、Gradle中的Build.gradle依赖项目
compile 'com.github.moduth:blockcanary-android:1.1.0'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
//inspection GradleCompatible
compile 'com.android.support:design:22.2.0'
compile 'com.jakewharton:butterknife:8.4.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0'
2、app中的Build.gradle依赖管理
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
3、布局文件
<com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/home_tab_rGroup"
android:id="@+id/recommend_parent"
>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/recommend"
/>
</com.lcodecore.tkrefreshlayout.TwinklingRefreshLayout>
4、代码
private void refresh(View view,int id){
TwinklingRefreshLayout refreshLayout = (TwinklingRefreshLayout) view.findViewById(id);
ProgressLayout header = new ProgressLayout(getActivity());
refreshLayout.setHeaderView(header);
refreshLayout.setFloatRefresh(true);
refreshLayout.setOverScrollRefreshShow(false);
refreshLayout.setHeaderHeight(140);
refreshLayout.setMaxHeadHeight(240);
refreshLayout.setOverScrollHeight(200);
refreshLayout.setEnableLoadmore(false);
header.setColorSchemeResources(R.color.Blue, R.color.Orange, R.color.Yellow, R.color.Green); refreshLayout.startRefresh();
refreshLayout.setOnRefreshListener(new RefreshListenerAdapter() {
@Override
public void onRefresh(final TwinklingRefreshLayout refreshLayout) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
refreshLayout.finishRefreshing();
}
}, 4000);
}
}); }