Java 如何将recyclerView项设置为不可单击但启用滚动
我使用RecyclerView实现了SwipeRefreshLayout。我之所以要这样做,是因为我的RecyclerView只在可点击的Cardview中显示一些小按钮。因此,如果有时设置为禁用,请单击并滚动启用。尝试下面的代码,但不工作,请帮助我。 我尝试了以下Java代码:Java 如何将recyclerView项设置为不可单击但启用滚动,java,android,xml,android-recyclerview,Java,Android,Xml,Android Recyclerview,我使用RecyclerView实现了SwipeRefreshLayout。我之所以要这样做,是因为我的RecyclerView只在可点击的Cardview中显示一些小按钮。因此,如果有时设置为禁用,请单击并滚动启用。尝试下面的代码,但不工作,请帮助我。 我尝试了以下Java代码: myRecyclerView.setEnabled(false); myRecyclerView.setClickable(false); Xml: 这个方法可以尝试一下。但是当你禁用Recyclerview时会
myRecyclerView.setEnabled(false);
myRecyclerView.setClickable(false);
Xml:
这个方法可以尝试一下。但是当你禁用Recyclerview时会出现一些问题。我的问题只是禁用按钮。将启用滚动 你能详细解释一下你想禁用的按钮在你的Recyclerview项目xml中吗?我建议你对按钮执行此代码,而不是Recyclerview…。表示你的按钮。setEnabled(false);您的按钮。可点击设置(错误);yourButton.setOnClickListener(null);我的活动按钮。此可单击按钮用于recyclerview项目,但不能禁用和启用。请发布您的适配器代码…….您能否解释有关您要禁用的按钮在recyclerview项目xml中的更多信息?我建议您对按钮执行此代码,而不是对recyclerview…….表示您的按钮。设置启用(false);您的按钮。可点击设置(错误);yourButton.setOnClickListener(null);我的活动按钮。可点击此按钮以禁用和启用recyclerview项。请发布您的适配器代码。。。。。。。。。。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="70"
android:layout_marginBottom="80dp"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/simpleSwipeRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/e_helptoolrecycler"
android:layout_width="match_parent"
android:clickable="false"
android:focusable="false"
android:scrollbars="vertical"
android:nestedScrollingEnabled="true"
android:isScrollContainer="true"
android:longClickable="false"
android:layout_height="wrap_content"
app:stackFromEnd ="true" >
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</RelativeLayout>
myRecyclerView .addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
return true;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});