Skip to content Skip to sidebar Skip to footer

Listview Onclicklistener Is Not Working In Drawer Layout

I am making a drawer having ListView in it. But surprisingly its not getting any onClickListener fired when I click on any list item. I have tried these things till now Making a A

Solution 1:

In your RelativeLayout set android:clickable="true". Or, a better approach would be to set an OnItemClickListener on your ListView.

yourListView.setOnItemClickListener(newAdapterView.OnItemClickListener() {

    @OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position, long id) {
        // TODO: do your stuff
    }
});

Solution 2:

Instead of putting the on click listener on view, do it on relativelayout after initializing it

Solution 3:

You need to set you list item click listener through ListView.setOnItemClickListener(...)

Solution 4:

Thanks everyone for giving suggestion for this issue. But I have found the cause for this abnormal behaviour. It is because of RelativeLayout (Outside Drawer Layout) defined in Activity's XML file (not item list XML). On removing that code, the click works as charm. :) Sorry for not including that code here..

You have to set a fragment in FrameLayout above drawer list view instead Relative Layout!

Post a Comment for "Listview Onclicklistener Is Not Working In Drawer Layout"