双面DrawerLayout,左侧工作 - 右侧没有

时间:2015-04-01 12:21:15

标签: android android-layout navigation-drawer drawerlayout actionbardrawertoggle

我正在使用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);
   }
}

0 个答案:

没有答案
相关问题