Document directory
Preface
During project development, the Listview Item must contain the button effect. After being developed in practice, after the button is placed in the Item, the effect of changing background color in the single row of ListView is no longer displayed.
Cause
The reason why ListView and other widgets that can trigger the click event cannot work together is that after adding other widgets, The itemclick event of ListView cannot be triggered and is blocked by the click events of other widgets.
Common solutions on the Internet
Set 1 set the root layout attribute in the xml template of Item
Android: descendantFocusability = "blocksDescendants"
As follows:
<RelativeLayout>
Android: descendantFocusability = "blocksDescendants"
Set 2. Set Properties in the <ImageButton> button control.
Android: focusable = "false"
Supplement: After this setting, click the button and the entire Item responds to the click effect. The displayed effect is not what we need.
What we need
1. The items of ListView can be selected.
2. The buttons in Item can be clicked at will without interfering with Item
Implementation Process
Use the image control or text control in ListView to replace the image button and common button, and set the click event in the Adapter.
Example:
// Set the text in the click Text Box Based on the data item, and set the Click Event TextView txt_remember((textview1_convertview.findviewbyid(r.id.txt _ Remember); txt_Remember.setOnClickListener (new TextView. onClickListener () {public void onClick (View v) {LibListViewAdapter. this. remove (LibListViewAdapter. this. getItem (1 ));}});
Effect:
Appendix:
Android Market of science back words-Level 4 edition: http://static.apk.hiapk.com/html/2012/07/719368.html