Advertisement
Guest User

Like this?

a guest
Mar 1st, 2017
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. public class MainActivity extends AppCompatActivity{
  2.  
  3.  
  4. MediaPlayer mp;
  5.  
  6. @Override
  7. protected void onCreate(Bundle savedInstanceState) {
  8. super.onCreate(savedInstanceState);
  9. setContentView(R.layout.activity_main);
  10.  
  11. }
  12.  
  13.  
  14. //sound onClick's
  15. public void sound1(View view){
  16. mp= MediaPlayer.create(this, R.raw.sound1);
  17. mp.start();
  18. }
  19. public void sound2(View view){
  20. mp= MediaPlayer.create(this, R.raw.sound2);
  21. mp.start();
  22. }
  23. public void sound3(View view){
  24. mp= MediaPlayer.create(this, R.raw.sound3);
  25. mp.start();
  26. }
  27. public void sound4(View view){
  28. mp= MediaPlayer.create(this, R.raw.sound4);
  29. mp.start();
  30. }
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement