1 year ago
#376282
Seb
Click Listener not triggered on CardView
I have created a recyclervuew which contain Cardview as below:
item.xml
<androidx.cardview.widget.CardView
android:id="@+id/tileLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="130dp"
android:clickable="true"
android:focusable="true"
android:layout_margin="4dp"
app:cardBackgroundColor="@color/brand06"
app:cardCornerRadius="15dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/actionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="110dp"
android:color="@color/transparent"
android:layout_margin="5dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/editLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:minHeight="110dp"
android:color="@color/transparent"
android:layout_margin="5dp">
When I am building the layout in the recyclerview, every time i am creation an item using item.xml
, I am tagging tileLayout
with a specific name using the command:
tileLayout.tag = name.toString()
name is an enum define as below:
enum class Name {
ITEM1,
ITEM2,
EDIT,
}
I have added a logic to check the name and when EDIT
is seen, I make actionLayout
GONE and set editLayout
VISIBLE
I register the onClickListener
on tileLayout
. It seems that when the editLayout
is visible and actionLayout
GONE, the click is not working in tileLayout
. when I do the opposite, the click is registered properly
I do not see why.
Any idea?
android
kotlin
onclicklistener
cardview
0 Answers
Your Answer