我見過this後,但沒有任何工作。這裏是我當前的代碼:Android - 快速點擊後,點擊按鈕的按鈕停止
private static MediaPlayer mp;
public void onClick(View v) {
mp = new MediaPlayer();
try {
mp.reset();
AssetFileDescriptor afd;
afd = getAssets().openFd("click.mp3");
mp.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getLength());
mp.prepare();
mp.start();
} catch (IllegalArgumentException | IllegalStateException | IOException e) {
e.printStackTrace();
}
increment(button, key, this);
}
當我快速地按一下按鈕,聲音停止
第二個選項是禁用點擊按鈕。但這是不正確的方式 –
我得到警告「布爾型」mp == null'總是'false'「。這是真的? –
請聲明mp是全局變量 –