gpt4 book ai didi

java - Android如何打开菜单/语音识别

转载 作者:行者123 更新时间:2023-12-02 04:20:21 25 4
gpt4 key购买 nike

这里是 Android Studio。我正在尝试打开菜单(右上角的三点菜单),但没有单击它。我正在使用语音识别命令。

我已经尝试以多种方式调用它,例如openOptionsMenu();, MapsActivityCurrentPlace.this.openOptionsMenu();等等,但没有用,菜单打不开。

// This is my menu - current_place_menu
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.current_place_menu, menu);
//optionsMenu = menu;
return true;
}

// Later in the code, this is the place I want to open my menu by recognizing the "menu" command

private int voiceR() {
switch (OPERATOR) {
case 'M':
//getMenuInflater();
//openOptionsMenu();
// MapsActivityCurrentPlace.this.openOptionsMenu(); // activity's onCreateOptionsMenu gets called
// optionsMenu.performIdentifierAction(R.id.groupp, 0);
//optionsMenu.performIdentifierAction(R.menu.current_place_menu, 0);
//getMenuInflater();
// MenuInflater inflater = getMenuInflater();
// inflater.inflate(R.menu.current_place_menu, optionsMenu);
//MenuInflater inflater = getMenuInflater();
//inflater.inflate(R.menu.current_place_menu, menu);
//Inflater.performIdentifierAction(R.id.groupp, 0);
//mShowMenu = true;
//invalidateOptionsMenu();
break;
case 'T':
break;
}
return -999;
}

预期结果将是打开的菜单和已实现的列表。目前,它可以识别该命令,但不会打开菜单。谢谢!

最佳答案

我尝试了其他东西,但仍然无法打开菜单。也许我的问题有点扭曲,但有人知道如何在不实际单击菜单的情况下执行单击菜单吗?

关于java - Android如何打开菜单/语音识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56638719/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com