Question

I want to do the following;

When you click on the pictures, you want to play audio files. I looked at examples from the internet but could not find an answer. How can I do this?

Was it helpful?

Solution

here is the code

    playButton = (ImageButton)findViewById(R.id.imageButton1);
   MediaPlayer mysong = MediaPlayer.create(this, R.raw.song);
      playbutton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {


                           mysong.start();
        }

    });

OTHER TIPS

Use a MediaPlayer (refer this). Inside the onClick of ImageView, call the start() function for your requirement.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top