在Application中执行
//设置刷新加载
public void refershHeaderAndFooter() {
sharedperferenceUtils = new SharedperferenceUtils(context, context.ACCOUNT_SERVICE);
language = sharedperferenceUtils.getLanguage();
SmartRefreshLayout.setDefaultRefreshHeaderCreator(new DefaultRefreshHeaderCreator() {
@NonNull
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
if (sharedperferenceUtils.getSkin() == 0) {
layout.setPrimaryColorsId(R.color.spannerColor, android.R.color.white);//全局设置主题颜色
} else if (sharedperferenceUtils.getSkin() == 1) {
layout.setPrimaryColorsId(R.color.children, android.R.color.white);//全局设置主题颜色
} else if (sharedperferenceUtils.getSkin() == 2) {
layout.setPrimaryColorsId(R.color.blue, android.R.color.white);//全局设置主题颜色
}
ClassicsHeader classicsHeader = new ClassicsHeader(context);
if (language.equals("chinese") || language.equals("")) {
classicsHeader.REFRESH_HEADER_PULLING = "下拉可以刷新";
classicsHeader.REFRESH_HEADER_REFRESHING = "正在刷新...";
classicsHeader.REFRESH_HEADER_LOADING = "正在加载...";
classicsHeader.REFRESH_HEADER_RELEASE = "释放立即刷新";
classicsHeader.REFRESH_HEADER_FINISH = "刷新完成";
classicsHeader.REFRESH_HEADER_FAILED = "刷新失败";
classicsHeader.REFRESH_HEADER_UPDATE = "M-d HH:mm";
} else {
classicsHeader.REFRESH_HEADER_PULLING = "Drop down can be refreshed";
classicsHeader.REFRESH_HEADER_REFRESHING = "Refreshing...";
classicsHeader.REFRESH_HEADER_LOADING = "Loading...";
classicsHeader.REFRESH_HEADER_RELEASE = "Release immediately refresh";
classicsHeader.REFRESH_HEADER_FINISH = "Refreshed";
classicsHeader.REFRESH_HEADER_FAILED = "Refresh failed";
classicsHeader.REFRESH_HEADER_UPDATE = "M-d HH:mm";
}
return classicsHeader.setSpinnerStyle(SpinnerStyle.Translate);//指定为经典Header,默认是 贝塞尔雷达Header
}
});
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreator(new DefaultRefreshFooterCreator() {
@NonNull
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter
ClassicsFooter classicsFooter = new ClassicsFooter(context);
if (language.equals("chinese") || language.equals("")) {
classicsFooter.REFRESH_FOOTER_PULLING = "上拉加载更多";
classicsFooter.REFRESH_FOOTER_RELEASE = "释放立即加载";
classicsFooter.REFRESH_FOOTER_LOADING = "正在加载...";
classicsFooter.REFRESH_FOOTER_REFRESHING = "正在刷新...";
classicsFooter.REFRESH_FOOTER_FINISH = "加载完成";
classicsFooter.REFRESH_FOOTER_FAILED = "加载失败";
classicsFooter.REFRESH_FOOTER_NOTHING = "没有更多数据了";
} else {
classicsFooter.REFRESH_FOOTER_PULLING = "More";
classicsFooter.REFRESH_FOOTER_RELEASE = "Release immediately load";
classicsFooter.REFRESH_FOOTER_LOADING = "Loading...";
classicsFooter.REFRESH_FOOTER_REFRESHING = "Refreshing...";
classicsFooter.REFRESH_FOOTER_FINISH = "Refreshed";
classicsFooter.REFRESH_FOOTER_FAILED = "Refresh failed";
classicsFooter.REFRESH_FOOTER_NOTHING = "Not More Data";
}
return classicsFooter.setSpinnerStyle(SpinnerStyle.Translate);
}
});
}
SmartRefreshLayout全局设置换肤
于 2019-06-26 17:02:01 首次发布