0

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

4

1 に答える 1

2

タイプミスがあります。メソッドの名前はonOptionsItemSelected()ではなくonOptionsItemsSelected()です。メソッドが呼び出されることはありません。

于 2012-12-28T10:52:21.680 に答える