Solution to the problem of listview clicking item without response in Android

If the listitem includes a button or check@R_ 760_ 2419 @ and other controls. By default, listitem will lose focus, resulting in failure to respond to item events. The most common solution is to set the descendantfocusability property in the layout file of listitem.

Layout file of item:

android:descendantFocusability

Defines the relationship between the ViewGroup and its descendants when looking for a View to take focus.

Must be one of the following constant values.

This property defines the relationship between the ViewGroup and its child controls when a gets the focus for the view.

Property has three values:

Beforedescendants: ViewGroup takes precedence over its subclass controls to get focus

Afterdescendants: ViewGroup gets focus only when its subclass control does not need to get focus

Blocksdecedents: ViewGroup overrides subclass controls to get focus directly

We use the third one.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>