Android development: some basic but useful knowledge (2)

Source: Internet
Author: User

1. onItemLongClick and onItemClick event Interception

To obtain both the onItemLongClick event and onItemClick event of a listview entry, you only need to return true in the onItemLongClick event trigger function.

2. Customize the CheckBox Style

Add the android: button attribute to the layout file. <喎?http: kf ware vc " target="_blank" class="keylink"> VcD4KPHA + PHByZSBjbGFzcz0 = "brush: java;"> Checkbox_selector.xml




3. The focus of a button or checkBox Item in ListView

When you customize a ListView, each Item contains a Button component or other component that can be clicked (usually button and checkbox) in addition to the text. When you click this item, it may not respond, this is because the focus is obtained by the button component. When you click an item, it is actually equivalent to clicking the button component.

Solution: add the following content to the root layout of the item.

Android: descendantFocusability = "blocksDescendants"

You can also add the following content to the button component:


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: 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.