How to handle list clicks for checkbox on nav drawer
I am working on an application where I have a right to left navigation drawer. In this navigation box, I need to handle the filters for the element.
I am inflating a ListView with a checkbox and text. The ListView fills with a checkbox and filters the text, but in my apps I can't handle the click event.
For example, When a user selects multiple checkboxes, then a click event needs to be fired and my application will be able to catch those checkboxes. But when I click on the marked event, the click is not handled. But when I inflate the ListView with text and images, I can handle click events.
For reference, my drawer layout is similar to the diagram below:
In my NavigationDrawerFragment class, I handle the click event like this:
private class FilterDrawerItemClickListener implements
ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
selectItem(position);
}
}
private void selectItem(int position) {
currentSelectedPosition = position;
if (drawerListView != null) {
drawerListView.setItemChecked(position, true);
}
if (drawerLayout != null ) {
drawerLayout.closeDrawer(fragmentContainerView);
}
// Fire the event off to the bus which.
// bus.post(new NavItemSelectedEvent(position));
bus.post(new FilterNavItemSelectedEvent(position));
}
When I removed the checkbox from the ListView that I was able to handle, but when I checked the checkbox in the ListView, I was unable to handle the click events.
I tried a lot of guys but had no idea. I think this is one of the common navigation drawer scenarios.
Thanx in advance!
source to share