why method setDrawerListener is deprecated?how to resolve it? [duplicate]
Asked Answered
U

3

5

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.

Unloose answered 4/6, 2016 at 11:44 Comment(1)
what is the problem you r facing? Please describe it then !!!Cannell
C
21

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.

Cannell answered 4/6, 2016 at 11:52 Comment(4)
It's funny how you rip off from other's answers. Almost every single answer you've posted is basically copy+paste. At-least give the credit to the post you copied from.Kreis
Just tell me ..where it is written not to copy n paste. I dint mark yes for my ans..so don't pin point.Cannell
Read this answer to the question here : meta.#251889. I believe in failure to give credit amounts to plagiarism. Considering almost every answer you've ever posted has been a copy, I can flag you if I want but I wont. Please keep it in mind the next time you attempt to answer. If you have found an answer somewhere, simply post a link in a comment.Kreis
Where? Right here.Metagenesis
U
1

Android official documentation states that setDrawerListener() should be replaced by addDrawerListener() setDrawerListener() Documentation

So it should work as they both accept the same arguments. You can read this also :addDrawerListener Documentation

in case you're missing something or the logic of your code has flaws.

You can also paste some of your code if the problem persists.

Unfortunate answered 4/6, 2016 at 12:10 Comment(0)
P
1

Well aparently google added this new method after API level 23.2.0.While both are same.Takes same arguments does same work... but in future it may not work somewhere i read.So its better to use

drawerLayout.addDrawerListener(actionBarDrawerToggle);

Primogenitor answered 21/4, 2017 at 6:12 Comment(1)
While this code may answer the question, providing additional context regarding how and/or why it solves the problem would improve the answer's long-term value. Remember that you are answering the question for readers in the future, not just the person asking now! Please edit your answer to add an explanation, and give an indication of what limitations and assumptions that apply. It also doesn't hurt to mention why this answer is more appropriate than others.Playroom

© 2022 - 2024 — McMap. All rights reserved.