Reasons for Onitemclicklistener not responding in Android development

Source: Internet
Author: User
Tags xmlns

Root cause: ListView (or other adapter view) does not get focus

Liezi:

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"

Android:layout_width= "Fill_parent"

android:layout_height= "Fill_parent"//Delayed One: fill_parent

android:orientation= "Vertical"

android:descendantfocusability= "blocksdescendants"//Delayed two

>

Right should be

<relativelayout xmlns:android= "Http://schemas.android.com/apk/res/android"

Android:layout_width= "Match_parent"

android:layout_height= "Match_parent"

android:orientation= "Vertical" >

Remember:

The primary layout (relativelayout) of adapter XML cannot be used Fill_parent

The reason is two.

One:

Reason: android:descendantfocusability= "blocksdescendants" is set in adapter XML

Note: The item below is ListView item

Android:beforefocusability ViewGroup gets focus before the subkey is processed

Android:afterfocusability ViewGroup gets focus after subkey processing

Android:blocksfocusability ViewGroup prevents the child from getting focus (the child of this subkey gets the focus)

Two: In Layout_ ... Set up the Fill_parent,

The principle is that fill_parent originally required this layout full screen, but ListView (or other adapter view) limits the item's height width.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.