OnListItemClick is not called on Listfragment
Hello I am having a problem with the onListItemClick method on ListFragment.
I have an Activity that contains 2 ListFragments. The first is sub-navigation and the second is some content. Sub nafigation werks works great and the onListItemClick event is called when clicking on the list item. But for the second ListFragment, nothing happens. This method is not called.
So far I have also tried to replace the Listfragment with a standard snippet and manually set the setOnItemClickListener. But it doesn't start when I click on the list entry. I also tried to test it with another listener (like onLongItemClick) but nothing happened.
These are the settings for my list.
<ListView
android:id ="@+id/mylistview"
android:layout_width ="match_parent"
android:layout_height ="match_parent"
android:divider ="@android:color/transparent"
android:dividerHeight ="10dp"
android:listSelector ="@android:color/transparent"
android:cacheColorHint ="@android:color/transparent"/>
Note that I have replaced the id with the default "@android: id / list" when using ListFragment.
Does anyone know what is wrong here? Could it be that other ListFragments get all calls to onListItemClick and don't let this get fired?
Here is the adapter attached to the list:
setListAdapter(new CustomRatingBarListAdapter(mListEntries,
getActivity(), R.layout.content_view_list_layout,
new int[] { R.id.list_item_text1 }, new String[] { TEXT});
source to share
Ok I found a bug. It was something completely different. Actually I had the rating bar as a list item, and even hardcoded it didn't cover the whole list item, it got all the click events somehow.
Changing the visibility for GONE has fixed the issue for now. So the problem was with the layout of one list item, not the adapter.
source to share
Modify adapter list items (strings) (* .xml file in layout / folder):
android:focusable="false"
Or, if you enter them programmatically, the code is:
yourChildView.setFocusable(false);
Do this with all the focusable UI components like Button, RatingBar, EditText, ToggleButton inside the view that makes up the list item (string), etc.
source to share