Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/226.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 停止在recyclerview中滚动_Android_Android Recyclerview - Fatal编程技术网

Android 停止在recyclerview中滚动

Android 停止在recyclerview中滚动,android,android-recyclerview,Android,Android Recyclerview,我需要修复在recyclerview中的滚动,如果用户删除其中一个可见视图,我只想在可用位置显示不可见视图。我试过做以下事情 增加 关于xml,以及 recyclerView.setHasFixedSize(false); 在Java上,但没有任何帮助,任何帮助都将是非常可观的 谢谢 更新 我想禁用滚动选项,用户只能在删除一个可见项后才能看到不可见项。我找到了一个非常简单的解决方案,可以停止循环视图中的所有垂直滚动。这花了我半天的时间才弄明白,但我认为现在真的很简单和优雅 创建一个java类,

我需要修复在recyclerview中的滚动,如果用户删除其中一个可见视图,我只想在可用位置显示不可见视图。我试过做以下事情

增加

关于xml,以及

recyclerView.setHasFixedSize(false);
在Java上,但没有任何帮助,任何帮助都将是非常可观的

谢谢

更新


我想禁用滚动选项,用户只能在删除一个可见项后才能看到不可见项。

我找到了一个非常简单的解决方案,可以停止循环视图中的所有垂直滚动。这花了我半天的时间才弄明白,但我认为现在真的很简单和优雅

创建一个java类,该类使用在recycler视图中找到的所有构造函数扩展recycler视图。在xml中,确保将其更改为新的小部件。然后您必须转换到方法:
onInterceptTouchEvent
computeVerticleScrollRange
。回收器视图中有一个错误,它仍然会中断滚动事件

因此:


现在,在代码中,你必须用“代码”>“Dababl”(代码)>方法和你的所有集合来控制你的循环器视图的状态。请考虑为关闭投票添加注释。请检查:这是可行的,我想知道为什么RecyclerView的StasScL卷()不做它应该做的事。(false)not disableVerticleScroll(也是方法名称中的一个输入错误)应为enableVerticalScroll
recyclerView.setHasFixedSize(false);
public class FooRecyclerView extends RecyclerView {

private boolean verticleScrollingEnabled = true;

public void enableVersticleScroll (boolean enabled) {
    verticleScrollingEnabled = enabled;
}

public boolean isVerticleScrollingEnabled() {
    return verticleScrollingEnabled;
}

@Override
public int computeVerticalScrollRange() {

    if (isVerticleScrollingEnabled())
        return super.computeVerticalScrollRange();
    return 0;
}


@Override
public boolean onInterceptTouchEvent(MotionEvent e) {

    if(isVerticleScrollingEnabled())
        return super.onInterceptTouchEvent(e);
    return false;

}



public FooRecyclerView(Context context) {
    super(context);
}
public FooRecyclerView(Context context, @Nullable AttributeSet attrs) {
    super(context, attrs);
}
public FooRecyclerView(Context context, @Nullable AttributeSet attrs,        int defStyle) {
        super(context, attrs, defStyle);
    }
}
RecyclerView
            android:id="@+id/task_sub_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
com.customGoogleViews.FooRecyclerView
            android:id="@+id/task_sub_list"
            android:layout_width="match_parent"
            android:layout_height="match_parent"