EDIT: SOLVED. If there's anything focusable in the XML of the items, it will break the touch of the list, in other words, android:focusable=false to all the checkboxes, switches or anything like that of ur list. And done =)
Ok so, here's my problem.
I wrote a app that uses tabs and fragments, and it all goes the way I want except for the thing that when I try to capture a onItemClick on a listView it does not even mark the row as touched/pressed/selected.
I've been reading a little bit about and many people have the same issue, but I did not found any responses that helped me at all.
I don't want to implement a ListFragment, in fact I don't even know how/why I should, and since all my code is already working, I don't know if implementing one will give me much more work to do, so, here it is:
Is it possible to implement a listener for a click on a listView, inside a fragment? and if it is, HOW?
PD: minSDK=14, tatgetSDK=15
the button will affect the listener, try avoid using button and re compile, it should work
If you want to pass data from fragment to any activity on Listview click then you can modify your code like...
This may be helpful Answer by raghunanadan in below link solved my problem
listview OnItemClick listner not work in fragment
Add this to the layout
android:descendantFocusability="blocksDescendants"
Here's a code snippet that'll do what you want.
People usually trip on this, see if you have got this covered:
All clicks and call backs (eg: the menu/actionbar callbacks) are sent to the activity the fragment is bound to, so they must be in the activity class and not the fragment class.
Two awesome solutions were this, if your extending ListFragment from a fragment, know that
mListView.setOnItemClickListener
wont be called before your activity is created, As @dheeraj-bhaskar implied. This solution ensured it is set when activity has been createdWhile looking at the source code for ListFragment, I came across this
An
onItemClickListener
object is attached and it callsonListItemClick()
As such the other similar solution, which works in the exact same way is to overrideonListItemClick()
Just put
in layout. For all textviews,buttons etc.