I am creating a RecyclerView on a fragment, and there is a button in one of the viewHolder(cell). But on the emulator, nothing happened after I clicked on that button. I set break points in the code for onClickListener, it doesn't even jump into the breakpoint.
Here is how I implement the button in the layout file:
<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" />
Here is my code in the adapter:
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);
}
I had checked the resource ID, the resource ID is correct. I had cleaned the project, rebuild the project, quite and relaunch Android Studio.