Reputation: 593
Hi i am making an android application. I want to play a default sound effect when i am typing in an EditText field. Any ideas how to do that?
Thanks
Upvotes: 0
Views: 480
Reputation: 10959
you can use textwatcher for that purpose
youredittext.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void afterTextChanged(Editable s) {
MediaPlayer mp = MediaPlayer.create(this, R.raw.yourmp3); // add mp3 file
mp.start();
}
});
Note : add yourmp3 in res->raw
folder
Upvotes: 1