我已经编写了创建 Android 菜单的代码,但是按钮在按下时不执行操作。我似乎无法弄清楚问题所在。
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.option_menu, menu);
return true;
}
public boolean onOptionsItemsSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.scan:
//Launch DeviceListActivity to see devices and scan
Intent serverIntent = new Intent(this, DeviceListActivity.class);
startActivityForResult(serverIntent, REQUEST_CONNECT_DEVICE);
System.out.println("Scan Pressed!");
return true;
case R.id.discoverable:
//ensure device is discoverable
ensureDiscoverable();
System.out.println("Discoverable Pressed!");
return true;
}
return super.onOptionsItemSelected(item);
}
我得到这个 logcat 错误:
12-28 10:19:05.769:W/KeyCharacterMap(1876):加载 keycharmap 文件“/system/usr/keychars/qtouch-obp-ts.kcm.bin”时出错。hw.keyboards.131072.devname='qtouch-obp-ts' 12-28 10:19:05.769: W/KeyCharacterMap(1876): 无法打开 keycharmap 文件 12-28 10:19:05.769: W/KeyCharacterMap( 1876):使用默认键盘映射:/system/usr/keychars/qwerty.kcm.bin