我能得到OptionsMenu點擊倍,安卓OptionsMenu點擊次數
我想獲得價值的onReceive使用,這樣
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
SubMenu fileMenu = menu.addSubMenu(0, 7, Menu.NONE, "歌曲");
fileMenu.add(0, 1, Menu.NONE, "A");
fileMenu.add(0, 2, Menu.NONE, "B");
fileMenu.add(0, 3, Menu.NONE, "C");
fileMenu.add(0, 4, Menu.NONE, "D");
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case 1:
Toast.makeText(this, "A", Toast.LENGTH_SHORT).show();
break;
case 2:
Toast.makeText(this, "B", Toast.LENGTH_SHORT).show();
break;
case 3:
Toast.makeText(this, "C", Toast.LENGTH_SHORT).show();
break;
case 4:
Toast.makeText(this, "D", Toast.LENGTH_SHORT).show();
break;
default:
return true;
}
return super.onOptionsItemSelected(item);
}
IntentFilter intent = new IntentFilter();
intent.addAction(BluetoothDevice.ACTION_FOUND);
registerReceiver(searchDevices, intent);
private BroadcastReceiver searchDevices = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
if(OptionsMenu click times == 2)
{
}
}
因爲我只是過程只有這部分,
請幫我理解如何解決提供意見謝謝