import android.support.v4.widget.DrawerLayout;
import android.support.v4.app.ActionBarDrawerToggle;
public class MainActivity extends Activity{
private DrawerLayout drawer;
private ActionBarDrawerToggle toggle;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
drawer = (DrawerLayout) findViewById(R.id.dra);
toggle = new ActionBarDrawerToggle(this, drawer, R.drawable.searchmap, R.string.drawer_open,R.string.drawer_close){
@Override
public void onDrawerClosed(View drawerView) {
super.onDrawerClosed(drawerView);
Log.i("mag", "關閉");
}
@Override
public void onDrawerOpened(View drawerView) {
super.onDrawerOpened(drawerView);
Log.i("mag", "打開");
}
};
drawer.setDrawerListener(toggle);
}
}
http://blog.csdn.net/jjwwmlp456/article/details/41206513