0
By clicking on the checkbox I run the list click (opens an Activity). To check the checkbox you have to keep pressed. I understand it could be this one click conflict over another. How can I then implement this to be able to click normally on the checkbox and not run the list click?
here the xml of recyclerView layout:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
android:background="@drawable/coner_radius"
android:elevation="1dp">
<TextView
android:id="@+id/tvCasa"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="casa"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@+id/tvVisitante"
app:layout_constraintEnd_toStartOf="@+id/tv1"
app:layout_constraintStart_toEndOf="@+id/tvHora"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tvVisitante"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:text="visitante"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@+id/tv2"
app:layout_constraintStart_toEndOf="@+id/tvHora"
app:layout_constraintTop_toBottomOf="@+id/tvCasa" />
<TextView
android:id="@+id/tv1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="0"
android:gravity="center"
android:text="0"
android:textSize="14sp"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintTop_toTopOf="parent"
tools:text="0" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="0"
android:gravity="center"
android:text="0"
android:textSize="14sp"
app:layout_constraintEnd_toStartOf="@+id/guideline3"
app:layout_constraintTop_toBottomOf="@+id/tv1"
tools:text="0" />
<TextView
android:id="@+id/tvHora"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:gravity="center"
android:text="00:00"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.890511" />
<CheckBox
android:id="@+id/checkBox5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:button="@drawable/check_box"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/guideline3"
app:layout_constraintTop_toTopOf="parent" />
Follow the recyclerView click:
rvJogos.addOnItemTouchListener(
new RecyclerItemClickListener(
getContext(),
rvJogos,
new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
jogo = listaDeJogos.get(position);
Intent intent = new Intent(getContext(), JogoActivity.class);
intent.putExtra("jogo", jogo);
startActivity(intent);
}
@Override
public void onLongItemClick(View view, int position) {
}
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i,
long l) {
}
}
)
);
I don’t understand what you want very well. You want to go to another Activity by clicking on a checkbox?
– Stênio Barroso de Moraes
you probably need some method like stopPropagation pro event not quit checkbox
– Vitor Ceolin
Searching better I understood that this implementation of click (despite being recommended by android) did not allow to mark the checkbox when clicking on it (that was the question). I implemented the click on the Adapter class and it worked well. Thank you so much for your answers.
– Lucas Fernandes