gpt4 book ai didi

Android按钮onLongClick,如何在长按释放按钮时获取监听器

转载 作者:行者123 更新时间:2023-11-30 03:10:36 27 4
gpt4 key购买 nike

<分区>

我正在关注 this tutorial在Android中实现一个录音机,其中包含以下代码,当按钮被按住时,开始录音,当按钮被释放时,停止录音,但是当按钮被释放时我找不到监听器,有什么建议吗?提前谢谢你

button.setOnLongClickListener(new View.OnLongClickListener() {          
@Override
public boolean onLongClick(View arg0) {
startRecording();
return false;
}
});

private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(voiceFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}

private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com