DrawerLayoutを使用しています。両側に2つの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);
}
}