android-studio - Why android:clickable="true" cannot trigger click events in the item layout of RecyclerView?
曾经蜡笔没有小新
曾经蜡笔没有小新 2017-06-06 09:52:55
0
2
1031

Why can't android:clickable="true" trigger a click event in the item layout of RecyclerView?
The original code is like this:

<TextView
        android:id="@+id/city_name"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:background="?android:attr/selectableItemBackground"
        android:clickable="true"
        android:gravity="center_vertical"
        android:padding="16dp"
        android:text=" 新都市 "
        android:textColor="#666666"
        android:textSize="14sp"/>

I found that when clicking, there was only a ripple effect but the click event could not be triggered. Later, I changed android:clickable="true" to false, and the rest remained unchanged, but there was a ripple effect and a click event. Why is this?

曾经蜡笔没有小新
曾经蜡笔没有小新

reply all(2)
巴扎黑

What event do you want? Whose response is your incident? TextView click, or RecyclerView Item click? These are two concepts.

过去多啦不再A梦

If you bind the click event to the item, when the clickable of TextView is true, it will consume the entire event sequence and cannot trigger the click callback of the item

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!