[Android 問題] How to Add a Button in ListView, and Make the Event of onClick and onItemClick Coexist?
2011-03-23 09:57
881 查看
If you add a Button on the view of each item in ListView,
the touch event is catched and reacted by the button instead of the ListView even outside the area of the Button.
The item can not be selected and switched.
It's a simplest solution that you can set the attribute android:focusable to be false to fix it as showed below:
<Button
android:id="@+id/contact_list_item_hd_button"
android:layout_width="30px"
android:layout_height="30px"
android:layout_gravity="center_vertical"
android:layout_marginRight="10px"
android:background="@drawable/contactlist_hd_button"
android:textSize="8sp"
android:focusable="false"
android:visibility="invisible"
/>
the touch event is catched and reacted by the button instead of the ListView even outside the area of the Button.
The item can not be selected and switched.
It's a simplest solution that you can set the attribute android:focusable to be false to fix it as showed below:
<Button
android:id="@+id/contact_list_item_hd_button"
android:layout_width="30px"
android:layout_height="30px"
android:layout_gravity="center_vertical"
android:layout_marginRight="10px"
android:background="@drawable/contactlist_hd_button"
android:textSize="8sp"
android:focusable="false"
android:visibility="invisible"
/>
相关文章推荐
- how to put the text on the left of a radio button in android
- How to alignment the center position of the button in Android?
- Android: How to download the latest zip Android Source Code easily and using it in Intellij
- How to add the cracked dlls in GAC and How to release
- How to avoid adding repeat submit the same data if you click the 'Refresh' button of Browser?
- GSR :the meaning of <load sharing elements> <refernce><refcount> in CEF and how to calculate them
- [Nuxt] Add Arrays of Data to the Vuex Store and Display Them in Vue.js Templates
- How to invoke the method of managed bean and render view in JSF when we are outside the lifecycle of JSF
- How to change the Text color of Menu item in Android?
- how to enable #ifdef macro in the command line of make?
- R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)
- How to handle the MouseLeftButtonDown and MouseLeftButtonUp events of the Button control?
- How to make an SDL window the child of another window in Win32
- How To Add/Increase The Size Of Redo Log Files In Rac Environment? (文档 ID 779306.1)
- [Drupal] How to add the js file and js code block in Drupal
- How to get and set the drawing order of layers in globe(获取并设置Globe图层的叠加次序:)
- How to hide my site and my document link in the right-top corner of sharepoint 2010
- The Defining Decade-Why Your Twenties Matter--And How to Make the Most of Them Now
- how to accepte the array of the checkbox in asp and in php
- How to slove the problem of Garbage Characters of Chinese and Errors of Images in Qt