zoukankan      html  css  js  c++  java
  • 菜单Menu显示三个点,不显示布局内容

    先说下menu的使用

    首先自定义一个menu选项

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        tools:context=".MainActivity">
        <item
            android:id="@+id/setting"
            android:icon="@mipmap/account_user_setting"
            android:title="设置"
            app:showAsAction="ifRoom" />
    </menu>

    然后再java代码中重写两个方法

     @Override
        public boolean onOptionsItemSelected(MenuItem item) {
            if (item.getItemId() == R.id.save) {return true;
            }
            return super.onOptionsItemSelected(item);
        }
    
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.account_menu_refund_expressage, menu);
            return true;
        }

    这样可以正常显示,不过有一点需要注意的是

    如果在充气这个menu菜单的时候,使用的是new 一个MenuInflater

     new MenuInflater(this).inflate(R.menu.account_menu_refund_expressage, menu);

    这样就会在右上角只显示三点,无论怎么调整xml文件都无用

  • 相关阅读:
    MySQL的存储引擎
    MySQL的索引及执行计划
    MySQL的SQL基础应用
    MySQL基础入门
    代码质量检测SonarQube
    Jenkins持续集成
    Git版本控制及gitlab私有仓库
    jumpserver跳板机
    Keepalived高可用服务
    well-known file is not secure
  • 原文地址:https://www.cnblogs.com/gloryhope/p/10144496.html
Copyright © 2011-2022 走看看