简体   繁体   English

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

[英]Toolbar menu item not clickable on android 4.4 (19)

I have a Android app for Android sdk version 23. Now I try to make it available for user using versions 19 to 23. All is working fine expect the toolbar in the head of the app. 我有一个适用于Android sdk版本23的Android应用程序。现在我尝试使用版本19到23的用户可用。所有工作正常,期望应用程序头部的工具栏。 I can't click an menu item. 我无法点击菜单项。 Nothing happend when I click. 点击时没有任何动静。 Also if I insert Log.v() there is no message in the debug view. 此外,如果我插入Log.v(),调试视图中没有消息。

What can I do? 我能做什么?

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);
    }

I experienced this issue too. 我也遇到过这个问题。 This was because I was using CoordinatorLayout which is a super-powered FrameLayout and thus was Overlaying the toolbar thus blocking interaction with the toolbar. 这是因为我使用的是CoordinatorLayout ,它是一个超级动力的FrameLayout,因此覆盖了工具栏,从而阻止了与工具栏的交互。 I solved the issue by replacing the CoordinatorLayout with a LinearLayout and giving it a vertical orientation. 我通过用LinearLayout替换CoordinatorLayout并给它一个垂直方向来解决这个问题。 You can also solve the issue by setting the toolbar position in relation to the parent as described here 您也可以通过设置解决问题toolbar所描述的相关位置父这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM