Android RecycleView 禁止滑动

释放双眼,带上耳机,听听看~!
import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
/**
 * 作者:陈鹤 on 2017/5/9.
 * 版本:v1.0
 */
//RecycleView禁止滑动
public class CustomGridLayoutManager extends LinearLayoutManager {
private boolean isScrollEnabled = true;
public CustomGridLayoutManager(Context context) {
super(context);
}
public void setScrollEnabled(boolean flag) {
this.isScrollEnabled = flag;
}
@Override
public boolean canScrollVertically() {
//Similarly you can customize "canScrollHorizontally()" for managing horizontal scroll
return isScrollEnabled && super.canScrollVertically();
}
}
       private CustomGridLayoutManager layoutManager;
        layoutManager = new CustomGridLayoutManager(getContext());
layoutManager.setScrollEnabled(false);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
mSpecRecycleView.setLayoutManager(layoutManager);

 

人已赞赏
Android文章

Android二维码扫描

2020-3-24 21:17:10

Android文章

android studio perView 无法预览

2020-3-24 23:47:52

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
有新消息 消息中心
搜索