Android 为什么在OnLongClickListener被调用时OnClickListener从未被调用

Android 为什么在OnLongClickListener被调用时OnClickListener从未被调用,android,kotlin,android-recyclerview,Android,Kotlin,Android Recyclerview,我有一个用于回收视图的适配器。它为视图注册单击侦听器: override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductCardViewHolder { val productView = LayoutInflater.from(parent.context).inflate(R.layout.product_card_item, parent, false) val holde

我有一个用于回收视图的适配器。它为视图注册单击侦听器:

 override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ProductCardViewHolder {
        val productView = LayoutInflater.from(parent.context).inflate(R.layout.product_card_item, parent, false)
        val holder = ProductCardViewHolder(productView)

        holder.itemView.setOnClickListener {
            Toast.makeText(it.context, "CLICK", Toast.LENGTH_SHORT).show()
        }

        holder.itemView.setOnLongClickListener {
            Toast.makeText(it.context, "LONG", Toast.LENGTH_SHORT).show()
            false
        }

        return holder
}
这就是布局(
R.layout.product\u card\u item



当我长按该项时,它会调用长单击侦听器,但当我只单击该项时,单击侦听器从未被调用,这是为什么?

您能显示
onBindViewHolder
方法吗?它应该可以工作,但可能在其他地方您正在覆盖此侦听器(或框架在引擎盖下执行此操作)@snachmsm我发现了这个问题,我认为,这似乎是Android Studio的问题,当我点击“应用更改并运行”时,侦听器不会被调用,就像没有应用更改一样。但在删除设备上的应用程序并重新安装后,它就可以正常工作了
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="200dp"
    android:layout_margin="8dp"
    app:cardCornerRadius="20dp"
    android:layout_height="300dp">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="4dp">

        <ImageView
            android:id="@+id/product_img"
            android:layout_width="match_parent"
            android:layout_height="60dp"
            android:layout_marginEnd="8dp" />

        <TextView
            android:id="@+id/product_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:textSize="16sp"
            android:layout_below="@id/product_img"
            android:textColor="@android:color/black" />
    </RelativeLayout>
</androidx.cardview.widget.CardView>