Andreas Konstantakos Andreas Konstantakos - 2 years ago 67
Java Question

Play sound when typing in EditText in android application

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?


Answer Source

you can use textwatcher for that purpose

 youredittext.addTextChangedListener(new TextWatcher() {
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {


            public void onTextChanged(CharSequence s, int start, int before, int count) {


            public void afterTextChanged(Editable s) {
          MediaPlayer mp = MediaPlayer.create(this, R.raw.yourmp3); // add mp3 file 

Note : add yourmp3 in res->raw folder

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download