Note that there are some explanatory texts on larger screens.

plurals
  1. POOpen DrawerLayout, perform action, then close it
    primarykey
    data
    text
    <p>So I want to animate my DrawerLayout in such a way that it is opened, an item is added to the menu in it, then it is closed.</p> <p>I tried a great deal of things, but the problem is that there is no delay between the "Open" and "Close" commands (or at least not a noticeable one) and so the animation never triggers.</p> <p>I really don't want to use a 'post delayed' with an arbitrary length because that seems dirty. I've tried manually overriding "onDrawerOpened()" in the listener - which WORKED, but then I can't CLOSE it AFTER the action is performed because you can't close it from within itself (meaning, if the 'closeDrawer(layout)' method is invoked from any sub-thread of the listener itself, it'll get a runtime error).</p> <p>So what I have is:</p> <pre><code> _drawerToggle = new ActionBarDrawerToggle(MainActivity.this, _drawerLayout, R.drawable.ic_drawer, R.string.drawerOpen, R.string.drawerClose) { /** Called when a drawer has settled in a completely closed state. */ public void onDrawerClosed(View view) { getActionBar().setTitle(_title); } /** Called when a drawer has settled in a completely open state. */ public void onDrawerOpened(View drawerView) { myAction(); //My action //If I try to invoke 'drawerClose()' here or in my action, a runtime error occurs } }; _drawerLayout.setDrawerListener(_drawerToggle); _drawerLayout.openDrawer(_mainFrame); //If I invoke 'drawerClose()' the entire thing is just too fast and the animations don't trigger </code></pre> <p>I even tried 'getAnimation()' on the DrawerLayout but it returns null so I can't use it to post a delayed action.</p> <p>Anyone have an idea how to approach this? Should I just used an arbitrary delay and hope it looks the same on all devices? Is there a way to close the drawer from within the listener? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload