SmartRefreshLayout 下拉刷新提示语言国际化
一,SmartRefreshLayout使用方法简要说明
1,在buidl.gradle中引入依赖
//SmartRefreshLayout上拉加载下拉刷新
implementation 'com.scwang.smartrefresh:SmartRefreshLayout:1.0.4-5'
//没有使用特殊Header,可以不加这行
implementation 'com.scwang.smartrefresh:SmartRefreshHeader:1.0.5.1'
2,在自己的Application中加入
//static 代码段可以防止内存泄露
static {
//设置全局的Header构建器
SmartRefreshLayout.setDefaultRefreshHeaderCreater(new DefaultRefreshHeaderCreater() {
@Override
public RefreshHeader createRefreshHeader(Context context, RefreshLayout layout) {
return new ClassicsHeader(context).setDrawableSize(20);
}
});
//设置全局的Footer构建器
SmartRefreshLayout.setDefaultRefreshFooterCreater(new DefaultRefreshFooterCreater() {
@Override
public RefreshFooter createRefreshFooter(Context context, RefreshLayout layout) {
//指定为经典Footer,默认是 BallPulseFooter
return new ClassicsFooter(context).setDrawableSize(20);
}
});
}
3,XML中
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/smartRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
//布局文件代码写这里
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
SmartRefreshLayout 详细使用方法
二,SmartRefreshLayout 实现提示语言国际化
将以下这段代码 放在定义的BaseActivity onCreate方法中即可
ClassicsHeader.REFRESH_HEADER_PULLDOWN =getString(R.string.xialakeyishuaxin);
ClassicsHeader.REFRESH_HEADER_REFRESHING = getString(R.string.zhengzaishuaxin);
ClassicsHeader.REFRESH_HEADER_LOADING = getString(R.string.zhengzaijiazhai);
ClassicsHeader.REFRESH_HEADER_RELEASE = getString(R.string.shifangshuaxin);
ClassicsHeader.REFRESH_HEADER_FINISH = getString(R.string.shuanxinwancheng);
ClassicsHeader.REFRESH_HEADER_FAILED = getString(R.string.shuaxinshibai);
ClassicsHeader.REFRESH_HEADER_SECOND_FLOOR = "释放进入二楼";
ClassicsHeader.REFRESH_HEADER_LASTTIME = getString(R.string.shangcigengxin);
ClassicsFooter.REFRESH_FOOTER_PULLUP = getString(R.string.shanglajiazhaigengduo);
ClassicsFooter.REFRESH_FOOTER_RELEASE = getString(R.string.shifanglijijiazhai);
ClassicsFooter.REFRESH_FOOTER_REFRESHING = getString(R.string.zhengzaishuaxin);
ClassicsFooter.REFRESH_FOOTER_LOADING = getString(R.string.zhengzaijiazhai);
ClassicsFooter.REFRESH_FOOTER_FINISH = getString(R.string.jiazhaiwancheng);
ClassicsFooter.REFRESH_FOOTER_FAILED = getString(R.string.jiazhaoshibai);
ClassicsFooter.REFRESH_FOOTER_ALLLOADED = getString(R.string.quanbujiazhaiwancheng);
然后在strings文件中写入不同语言即可实现语言切换!
本文地址:https://blog.csdn.net/NewActivity/article/details/107128782