Encountered a problem:
The onitemclicklistener of listview listens to events. If a button in the item also listens to events, it cannot listen to events at the same time, but it does not respond.
Solution:
The essence of the solution is to transfer the event to a view in the item without The onitemclicklistener event.
Solution 1. Obtain the view of the outermost layer of an item
At this time, if you set listview. setonitemlongclicklistener () for listview; after the event, it is found that only long-pressed edittext can trigger the item event. All methods for getting the focus and losing the focus are tried. There is no solution: the simplest solution is to get the layout of the outermost layer of the item in the getview method: viewholder. ll_item= (Linearlayout) convertview. findviewbyid (R.ID. Ll_item); then set the layout event in the getview method: viewholder. ll_item.setonlongclicklistener (NewOnlongclicklistener () {@ overridePublicBoolean onlongclick (view v) {}); you can click edittext to input text or item to trigger the event you need!
Solution 2: Add a view overwrite to the bottom layer of the item
Side effect: other views on the view cannot monitor events. (Not tested)
Side effects
Solution 3. This articleArticleIt seems that the problem of simultaneous listening can be solved.
Http://txlong-onz.iteye.com/blog/907186
In addition, you cannot add both listview and imageview listeners by using this method. In the web search, some attributes are not added to XML, and the XML root node in list configuration cannot be added.Android: descendantfocusability = "blocksdescendants"And addAndroid: focusable = "false", AboveCode.
These are related to the view and listview focus issues:
Http://blog.sina.com.cn/s/blog_a855dc2c01014ith.html
Solution 4: (tested) completely solved
Similar to the preceding figure, a view is used at the bottom to listen to events. Use framelayout in item to solve the problem completely.
If a listener is written to the upper-layer view, when an event is monitored, the event will be handed over for processing and will not be passed down;
If the upper view does not have a listener, the event will be passed down until the view listens to and processes the event, or ends at the bottom.
the upper view does not affect the lower view listening events.