我正在使用DrawerLayout。我有两个ListView。通过单击ActionBar上的左上角按钮,左侧工作正常。右侧也在工作。但是右侧工作只能从左向右滑动。我想在ActionBar的右上角放一个按钮,打开右侧(就像ActionBar上的左上角一样)。我怎么能这样做?
这是我正在使用的ActionBarDrawerToggle代码;
public class MainActivity extends ActionBarActivity {
private ActionBarDrawerToggle mDrawerToggle;
//....
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//....
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.drawable.sidebar, R.string.drawer_open,
R.string.drawer_close) {
public void onDrawerClosed(View view) {
invalidateOptionsMenu();
Toast.makeText(getApplicationContext(),"Menu closed",Toast.LENGTH_SHORT).show();
}
public void onDrawerOpened(View drawerView) {
invalidateOptionsMenu();
Toast.makeText(getApplicationContext(),"Menu opened",Toast.LENGTH_SHORT).show();
}
};
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
}