Search code examples
androidandroid-actionbar-compat

ActionBarCompat - On draw open/closed not being called?


ActionBar actionBar = getSupportActionBar();
mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.drawer_list_item, DrawTitles));
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open, R.string.drawer_close) {
    public void onDrawerClosed(View view) {
        actionBar.setTitle("fd");
        invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }

    public void onDrawerOpened(View drawerView) {
        Log.e("KFF", "Draw Open");
        String mystring = "reewr";
        SpannableString s = new SpannableString(mystring);
        s.setSpan(new TypefaceSpan(MainActivity.this, "cubano"), 0, s.length(),
        Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        actionBar.setTitle(s);
        invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
    }
};

No matter what i seem to try, the onDrawerOpened or the Closed are not being called, despite everything working as expected, including the action bar toggle icon and all functionality.


Solution

  • Solved.

    Seems as though it was the trivial matter of :

     mDrawerLayout.setDrawerListener(mDrawerToggle);
    

    before i'd setup the actual DrawerToggle, it was initializing and not throwing any errors because the variable is the right type, just simply null.

    Something to keep an eye on.