Created
June 7, 2013 06:30
-
-
Save akshaydashrath/5727406 to your computer and use it in GitHub Desktop.
Support for ActionbarSherlock with the new DrawerLayout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity; | |
import android.support.v4.app.ActionBarDrawerToggle; | |
import android.support.v4.view.GravityCompat; | |
import android.support.v4.widget.DrawerLayout; | |
import com.actionbarsherlock.view.MenuItem; | |
/** | |
* Created by akshay on 06/06/2013. | |
*/ | |
public class ActionBarDrawerToggleCompat extends ActionBarDrawerToggle { | |
private final DrawerLayout drawerLayout; | |
private static final int ID_HOME = 0x0102002c; | |
public ActionBarDrawerToggleCompat(Activity activity, DrawerLayout drawerLayout, int drawerImageRes, int openDrawerContentDescRes, int closeDrawerContentDescRes) { | |
super(activity, drawerLayout, drawerImageRes, openDrawerContentDescRes, closeDrawerContentDescRes); | |
this.drawerLayout = drawerLayout; | |
} | |
public boolean onSupportOptionsItemSelected(MenuItem item) { | |
if (item != null && item.getItemId() == ID_HOME && isDrawerIndicatorEnabled()) { | |
if (drawerLayout.isDrawerVisible(GravityCompat.START)) { | |
drawerLayout.closeDrawer(GravityCompat.START); | |
} else { | |
drawerLayout.openDrawer(GravityCompat.START); | |
} | |
} | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment