Skip to content Skip to sidebar Skip to footer

Navigation Drawer Items Not Registering Click Event

I am struggling to get the Navigation drawer items to register and start and intent for a new activity. The drawer opens fine and is displayed correctly but nothing happens when I

Solution 1:

The problem is the z ordering. When you expand the list in onDrawerOpened put:

mDrawerList.bringToFront();
mDrawerLayout.requestLayout();

In this post explain the problem and how fix it: http://vardhan-justlikethat.blogspot.com.es/2014/05/android-custom-navigation-drawer-not.html

Solution 2:

Fixed a similar issue by adding drawerView.bringToFront(); to

@OverridepublicvoidonDrawerOpened(View drawerView) {

} 

Solution 3:

If you have a list in Navigation Drawer then just write the code and make listview clickable:

list.bringToFront();
drawerLayout.requestLayout(); 

Solution 4:

You should check if you have android:animateLayoutChanges="true" attribute on ListView parent(in layout resource). Removing that attribute worked for me.

Solution 5:

It seems like the your DrawerItemClickListener.class does not work as the only time the selectItem() method is called is at the end of your activities onCreate() at selectItem(0);

Instead of calling

mDrawerList.setOnItemClickListener(newDrawerItemClickListener());

you can use this as a parameter and let you Activity implement the ListView.OnItemClickListener itself.

publicclassMyActivityextendsActivityimplementsListView.OnItemClickListener {

    publicvoidonCreate(Bundle savedInstanceState) {
        [...]
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        [...]
        mDrawerList.setOnItemClickListener(this);
        [...]
     }

    [...]    

    @OverridepublicvoidonItemClick(AdapterView<?> parent, View view, int position, long id) {
        selectItem(position);
    }

    privatevoidselectItem(int position) {
        switch (position) {
            case1:
                [...]
                startActivity(newIntent(this, SplashScreen.class));
                break;
            [...]
            default:
            break;
        }
        [...]
    }
    [...]
}

Post a Comment for "Navigation Drawer Items Not Registering Click Event"