문제

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