I'm trying to hide a specific die after it has been selected and used.
However, it keeps hiding all the ImageView
below the one select
I've tried using different containers but can't seem to figure it out
This is XML for the dice for 3 of the dice:
<ImageView
android:id="@+id/img4"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:onClick="Select"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline3"
app:srcCompat="?attr/colorControlHighlight" />
<ImageView
android:id="@+id/img3"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:onClick="Select"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline2"
app:srcCompat="?attr/colorControlHighlight" />
<ImageView
android:id="@+id/img1"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:onClick="Select"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="?attr/colorControlHighlight" />
<androidx.constraintlayout.widget.Guideline
This is the method used to hide the dice:
public void RemoveDice(int pos) {
switch (pos) {
case 0:
img1.setVisibility(View.INVISIBLE);
case 1:
img2.setVisibility(View.GONE);
case 2:
img3.setVisibility(View.GONE);
case 3:
img4.setVisibility(View.INVISIBLE);
case 4:
img5.setVisibility(View.GONE);
case 5:
img6.setVisibility(View.GONE);
case 6:
img7.setVisibility(View.GONE);
case 7:
img8.setVisibility(View.INVISIBLE);
case 8:
img9.setVisibility(View.GONE);
}
}
This shows before selecting Blue 6
https://prnt.sc/peufqr
This after the selected die has been removed
https://prnt.sc/peugn7
I think my problem lies somewhere in the XML file but I am unsure what containers to use to prevent this.