亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

工具欄 SDK 29 中未顯示的菜單項

工具欄 SDK 29 中未顯示的菜單項

忽然笑 2023-06-04 16:55:46
我遇到的問題是菜單按鈕未顯示在工具欄中。我將一個按鈕設置為始終顯示,將一個按鈕設置為僅在有空間時顯示。沒有顯示。這是使用 Android SDK 29 (Q) 編譯的。(我在 Stack Overflow 上搜索過類似的問題,但其他問題至少是幾年前寫的,并且使用的是較舊的 SDK。)activity_main.xml   <?xml version="1.0" encoding="utf-8"?>    <androidx.constraintlayout.widget.ConstraintLayout     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"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:background="@color/tealBlue"    tools:context=".view.MainActivity">    <androidx.appcompat.widget.Toolbar        app:layout_constraintTop_toTopOf="parent"        android:id="@+id/toolbar_top_main"        android:layout_width="match_parent"        android:layout_height="wrap_content"        android:background="?attr/colorPrimary"        android:minHeight="?attr/actionBarSize"        android:theme="?attr/actionBarTheme"        tools:menu="@menu/top_menu_overflow"        />    <ExpandableListView        android:id="@+id/expandableListViewPolls"        android:layout_width="match_parent"        android:layout_height="0dp"        android:layout_marginTop="8dp"        android:layout_marginBottom="8dp"        android:indicatorLeft="?    android:attr/expandableListPreferredItemIndicatorLeft"        app:layout_constraintBottom_toBottomOf="parent"        app:layout_constraintTop_toBottomOf="@+id/toolbar_top_main"        tools:layout_editor_absoluteX="16dp" />    ...
查看完整描述

1 回答

?
慕少森

TA貢獻2019條經驗 獲得超9個贊

發現了問題。我需要在我的 MainActivity.java 中添加以下方法來擴充菜單項。


@Override public boolean onCreateOptionsMenu(Menu menu) {

    MenuInflater inflater = getMenuInflater();

    inflater.inflate(R.menu.top_menu_overflow, menu);

    return true; 

}


查看完整回答
反對 回復 2023-06-04
  • 1 回答
  • 0 關注
  • 133 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號