سؤال

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