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?

有帮助吗?

解决方案

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();
        }

    });

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top