工具栏菜单项无法在Android 4.4(19)上单击

bae*_*n83 6 android toolbar android-toolbar

我有一个适用于Android sdk版本23的Android应用程序.现在我尝试使用版本19到23的用户可用.所有工作正常,期望应用程序头部的工具栏.我无法点击菜单项.点击时没有任何动静.此外,如果我插入Log.v(),调试视图中没有消息.

我能做什么?

public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        if (id == R.id.action_refresh) {
            doRefreshGames(item);
            return true;
        }

        if(id == R.id.action_rss){
            Intent rssIntent = new Intent(AmericanFootball.this, AmericanFootballRSS.class);
            //if you need to pass data:
            Bundle mBundle = new Bundle();
            mBundle.putString("myKey", "comeon");
            rssIntent.putExtras(mBundle);
            startActivity(rssIntent);
        }

        if (mDrawerToggle.onOptionsItemSelected(item)) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
Run Code Online (Sandbox Code Playgroud)

Esi*_*ngs 1

我也经历过这个问题。这是因为我使用的CoordinatorLayout是一个功能强大的 FrameLayout,因此覆盖了工具栏,从而阻止了与工具栏的交互。CoordinatorLayout我通过用a替换LinearLayout并给它一个垂直方向解决了这个问题。toolbar您还可以通过设置相对于父级的位置 来解决问题,如此处所述