Android onClick回调未从recyclerView中的按钮调用

Android onClick回调未从recyclerView中的按钮调用,android,android-recyclerview,android-button,Android,Android Recyclerview,Android Button,我正在片段上创建一个RecyclerView,其中一个viewHolder(单元格)中有一个按钮。但是在模拟器上,我点击了那个按钮后什么也没发生。我在onClickListener的代码中设置了断点,它甚至没有跳入断点 以下是我如何在布局文件中实现按钮: <Button android:id="@+id/add_to_list_button" android:layout_width="35dp" android:layout_height="35dp" a

我正在片段上创建一个RecyclerView,其中一个viewHolder(单元格)中有一个按钮。但是在模拟器上,我点击了那个按钮后什么也没发生。我在onClickListener的代码中设置了断点,它甚至没有跳入断点

以下是我如何在布局文件中实现按钮:

<Button
    android:id="@+id/add_to_list_button"
    android:layout_width="35dp"
    android:layout_height="35dp"
    android:layout_marginBottom="8dp"
    android:layout_marginStart="8dp"
    android:layout_marginTop="8dp"
    android:text=""
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

我已经检查了资源ID,资源ID是正确的。我清理了项目,重建了项目,并重新启动了Android Studio。

只是取消了其他功能,你在其他地方没有任何名为“添加到列表”的按钮?而且这绝对是你正在膨胀的正确布局?当您在
mAddButton
上设置另一个属性时会发生什么情况,例如
setEnabled(false)
?您可以发布整个适配器代码吗?您是否尝试过其他方法,例如从适配器更改按钮的文本?
Button mAddButton

mAddButton = (Button) itemView.findViewById(R.id.add_to_list_button);
mAddButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.d("test button","testinbtn");
        AddContactToList(GlobalPosition);
    }
});

private static void AddContactToList(int pos) {
    String list_id = mUnsubscribedList.get(pos - 2 - mSubscribedList.size()).getList_id();
    apiInstance.AddContactToTheList(contact.getContactID(), list_id);
}