Java GridView中的复选框仍然可单击,而clickable=false
我已经制作了一个gridview(在一个片段中),其中包含一个适配器和项目的布局。该布局包括一个用于显示图片的ImageView、一个复选框和另一个用于显示指示器的ImageView,该指示器指示图片是否仅为图片或视频的缩略图。布局如下:Java GridView中的复选框仍然可单击,而clickable=false,java,android,android-gridview,Java,Android,Android Gridview,我已经制作了一个gridview(在一个片段中),其中包含一个适配器和项目的布局。该布局包括一个用于显示图片的ImageView、一个复选框和另一个用于显示指示器的ImageView,该指示器指示图片是否仅为图片或视频的缩略图。布局如下: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" and
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content" android:layout_height="wrap_content">
<ImageView
android:id="@+id/ivGridMedia"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:contentDescription="@string/imgObjectMediaDesc"/>
<CheckBox
android:id="@+id/checkBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/ivGridMedia"
android:layout_alignEnd="@+id/ivGridMedia"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false" />
<ImageView
android:id="@+id/vidIndicator"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_centerInParent="true"
android:focusable="false"
android:focusableInTouchMode="false"
android:contentDescription="@string/imgPlayDesc"
android:visibility="gone"
android:src="@drawable/icon_play"/>
</RelativeLayout>
我正在尝试使这个GridView像gallery应用程序一样工作,因此(将来)复选框在开始时是不可见的,但只要长时间单击该项目,它就会可见,用户将能够选择一些图片进行处理
我不希望复选框可聚焦或可单击(我希望能够单击项目以选中复选框),但即使我已将复选框设置为不可聚焦或可单击,我仍然可以单击它,有人知道如何解决此问题吗?您可以设置
android:enabled=“false”
要禁用复选框
请尝试android:enabled=“false”
@AbhishekV,谢谢!伟大的很高兴它起作用了。