I know what's setOnItemClickListener, but It set the listen to whole item. If my item contains a button to which I want to set listener, setOnItemClickListener doesn't help. I tried set listener in getView, but in vain.
            Asked
            
        
        
            Active
            
        
            Viewed 6,652 times
        
    1 Answers
3
            Check this post for a nice solution: http://androidforbeginners.blogspot.com/2010/03/clicking-buttons-in-listview-row.html
(it actually works for any View: http://developer.android.com/reference/android/view/View.html#attr_android:onClick)
 
    
    
        Aleadam
        
- 40,203
- 9
- 86
- 108
- 
                    I’m really confused. here(http://stackoverflow.com/questions/5973917/why-does-the-viewholder-pattren-work) said every item in ArrayAdapter shared only one view instance. so that how can we get different views by getParent? – Lai Yu-Hsuan May 13 '11 at 02:13
- 
                    I don't think that is correct. Every row will share the *resource* that is being inflated perhaps, but not the *View*. You cannot have one View displayed twice at the same time. – Aleadam May 13 '11 at 03:30
- 
                    You solve my new problem. how about the older one: why can we cache the reference to "different" instances? – Lai Yu-Hsuan May 13 '11 at 03:41
- 
                    I got a exact answer on IRC for the old problem. I will post on that page. – Lai Yu-Hsuan May 13 '11 at 05:16
