触摸屏幕

时间:2015-09-17 12:02:53

标签: android android-layout android-activity navigation-drawer android-navigation-drawer

我是这个Android的新手。在这里,当我点击时,我遇到了一个问题 在导航抽屉项目然后它给出其他项目然后触摸屏幕然后导航抽屉关闭但后退按钮仍在那里。

我把 mDrawerLayout.ontouchlistener 它确实有效,但我想要点击屏幕上的那个图标。我不想要后退按钮

当我点击导航抽屉内的类别项目时:

enter image description here

然后我在ExpandableListView中添加了另一个具有不同ArrayList的适配器:

enter image description here

但是当我触摸屏幕然后关闭导航抽屉,但后面的图标仍然存在:

enter image description here

2 个答案:

答案 0 :(得分:0)

  getSupportActionBar().setDisplayHomeAsUpEnabled(false);
  getSupportActionBar().setHomeButtonEnabled(false);

在您的活动中。

答案 1 :(得分:0)

我在developers.android.com上查了一下。他们给了一个小解决方案。希望这有效。



 private ActionBarDrawerToggle mDrawerToggle;
    ...
     private DrawerLayout mDrawerLayout;
    public void onCreate(Bundle savedInstanceState) {
        ...

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerToggle = new ActionBarDrawerToggle(
                this,                  /* host Activity */
                mDrawerLayout,         /* DrawerLayout object */
                R.drawable.ic_drawer,  /* nav drawer icon to replace 'Up' caret */
                R.string.drawer_open,  /* "open drawer" description */
                R.string.drawer_close  /* "close drawer" description */
                ) {

            /** Called when a drawer has settled in a completely closed state. */
            public void onDrawerClosed(View view) {
                super.onDrawerClosed(view);
                getActionBar().setTitle(mTitle);
            }

            /** Called when a drawer has settled in a completely open state. */
            public void onDrawerOpened(View drawerView) {
                super.onDrawerOpened(drawerView);
                getActionBar().setTitle(mDrawerTitle);
            }
        };

        // Set the drawer toggle as the DrawerListener
        mDrawerLayout.setDrawerListener(mDrawerToggle);

        getActionBar().setDisplayHomeAsUpEnabled(true);
        getActionBar().setHomeButtonEnabled(true);
    }

    @Override
    protected void onPostCreate(Bundle savedInstanceState) {
        super.onPostCreate(savedInstanceState);
        // Sync the toggle state after onRestoreInstanceState has occurred.
        mDrawerToggle.syncState();
    }

    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        mDrawerToggle.onConfigurationChanged(newConfig);
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Pass the event to ActionBarDrawerToggle, if it returns
        // true, then it has handled the app icon touch event
        if (mDrawerToggle.onOptionsItemSelected(item)) {
          return true;
        }
        // Handle your other action bar items...

        return super.onOptionsItemSelected(item);
    }

    ...
}