0
我正在編寫代碼來改變TextView,當按下音量上/下鍵來更新系統卷的TextView時%set.I現在有這個代碼可以工作一次,但它覆蓋了up /有沒有辦法重新編寫它或將其排除在overid之外?onKeyDown無法正常工作
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
//system volume
int curVolume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
int i = curVolume;
String aString = Integer.toString(i);
TextView sysVol = (TextView)findViewById(R.id.systemVolume);
sysVol.setText(aString);
sysVol.invalidate();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
如果您不'返回true並始終調用超類實現,會發生什麼? –