Skip to content

Commit 5032741

Browse files
committed
some issues fixes for onclick listeners2
1 parent c2491d4 commit 5032741

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

app/src/main/res/layout/custom_recycler_child.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
android:layout_marginStart="10dp"
4040
android:layout_marginEnd="10dp"
4141
android:layout_marginTop="5dp"
42+
android:clickable="false"
4243
android:text="Title goes here"
4344
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
4445
app:layout_constraintTop_toTopOf="parent"
@@ -50,6 +51,7 @@
5051
android:layout_width="0dp"
5152
android:layout_height="wrap_content"
5253
android:layout_marginTop="5dp"
54+
android:clickable="false"
5355
android:text="Description goes here hereDescription goes here"
5456
android:textAppearance="@style/TextAppearance.AppCompat.Small"
5557
app:layout_constraintStart_toStartOf="@id/titleTextView"

easylistwidget/src/main/java/com/sayan/easylistwidget/adapters/CustomRecyclerAdapter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,8 @@ private void setOnClickListenersToChild(EasyListView.OnItemClickListener onClick
9898
if (isViewGroup) {
9999
for (int i = 0; i < itemViewGroup.getChildCount(); i++) {
100100
View child = itemViewGroup.getChildAt(i);
101-
child.setOnClickListener(new CustomOnClickListener(onClickListener, position));
101+
if (child.isClickable() || child.isFocusable())
102+
child.setOnClickListener(new CustomOnClickListener(onClickListener, position));
102103
setOnClickListenersToChild(onClickListener, child, position);
103104
}
104105
}
@@ -109,11 +110,12 @@ private static class CustomOnClickListener implements View.OnClickListener {
109110
private final EasyListView.OnItemClickListener onClickListener;
110111
private final int finalPosition;
111112

112-
CustomOnClickListener(EasyListView.OnItemClickListener onClickListener, int finalPosition){
113+
CustomOnClickListener(EasyListView.OnItemClickListener onClickListener, int finalPosition) {
113114

114115
this.onClickListener = onClickListener;
115116
this.finalPosition = finalPosition;
116117
}
118+
117119
@Override
118120
public void onClick(View v) {
119121
onClickListener.onClick(v, finalPosition);

0 commit comments

Comments
 (0)