Skip to content

Instantly share code, notes, and snippets.

@lalbuquerque
Forked from quentin7b/drawer_open.java
Last active August 29, 2015 14:23
Show Gist options
  • Save lalbuquerque/0672aef3a9c74fbf6187 to your computer and use it in GitHub Desktop.
Save lalbuquerque/0672aef3a9c74fbf6187 to your computer and use it in GitHub Desktop.
/**
* As we use app compat it seems Solo#setNavigationDrawer is not doing well (drawer does not open, but the button is clicked)
* Same result for clickOnView(getView(android.R.id.home))
*
* This code opens the navigation drawer on the main thread
* Be aware : you need to provide your DrawerLayout id (you can do it in params)
*/
public void openCompatNavigationDrawer() {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
public void run() {
// You need to replace with your DrawerLayout id, or set it in params
((DrawerLayout) mSolo.getView(R.id.drawer_layout)).openDrawer(Gravity.LEFT);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment