How to replace deprecated android.support.v4.app.ActionBarDrawerToggle

后端 未结 4 1968
难免孤独
难免孤独 2020-11-28 21:49

Yesterday (17-10-2014) I have update Android SDK and support-library-v4.jar of my App, now I get deprecation warning related to ActionBarDrawerToggle

4条回答
  •  孤街浪徒
    2020-11-28 22:19

    There's no need for you to use super-call of the ActionBarDrawerToggle which requires the Toolbar. This means instead of using the following constructor:

    ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, Toolbar toolbar, int openDrawerContentDescRes, int closeDrawerContentDescRes)
    

    You should use this one:

    ActionBarDrawerToggle(Activity activity, DrawerLayout drawerLayout, int openDrawerContentDescRes, int closeDrawerContentDescRes)
    

    So basically the only thing you have to do is to remove your custom drawable:

    super(mActivity, mDrawerLayout, R.string.ns_menu_open, R.string.ns_menu_close);
    

    More about the "new" ActionBarDrawerToggle in the Docs (click).

提交回复
热议问题