How would I go about creating more than one OnClickListener for one Button. Suppose I have an application that starts recording audio on the first click and stops recording on the next click. How would I go about doing that ?
I tried using two OnClickListeners but that didn’t work.
EDIT
I am trying to make some more implementations to my current app. I am trying to change the text on the button during run time if the audio is recording. I would like the text on the button to say Recording.. and after 1 second it should say Recording… . This should happen the entire time while the audio is recording . I tried implementing this but I couldn’t get it to work. Here is my code:
audio.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if(audioRecording == false){
audio.setText("Recording..");
startRecording();
audioRecording = true;
while(!audio.isPressed()){
audio.setText("Recording...");
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
attachVoice.setText("Recording..");
}
}
else{
audio.setText("Press to Record");
stopRecording();
audioRecording = false;
}
}
});
You can do it loads of ways, the point is you somehow have to save the state of your application. Here is a simple example: