why method setDrawerListener is deprecated?how to resolve it?

mehrdad372 picture mehrdad372 · Jun 4, 2016 · Viewed 11.6k times · Source

In my android application I see the following error:

setDrawerListener(android.support.v4.widget.Drawer Layout.DrawerListener)' is deprecated

How i can resolve this?

In one answer I see use addDrawerListener() instead setDrawerListener but it does not seem to work.

Answer

prat picture prat · Jun 4, 2016

Instead of using setDrawerListener(), you could use addDrawerListener().

public void setDrawerListener(DrawerLayout.DrawerListener listener) Sets a listener to be notified of drawer events.

Note that this method is deprecated and you should use addDrawerListener(DrawerLayout.DrawerListener) to add a listener and removeDrawerListener(DrawerLayout.DrawerListener) to remove a registered listener.