1Button one = (Button) this.findViewById(R.id.button1);
2final MediaPlayer mp = MediaPlayer.create(this, R.raw.soho);
3one.setOnClickListener(new OnClickListener(){
4
5 public void onClick(View v) {
6 mp.start();
7 }
8});
1public class MainActivity extends AppCompatActivity{
2 Button bt;
3
4 @Override
5 protected void onCreate(Bundle savedInstanceState){
6 super.onCreate(savedInstanceState);
7 setContentView(R.layout.activity_main);
8 bt = (Button)findViewById(R.id.clickme);
9 final MediaPlayer mp = MediaPlayer.create(this, R.raw.sample);
10 bt.setOnClickListener(new View.OnClickListener(){
11 @Overridepublic void onClick(View view){
12 np.start();
13 }
14 }
15 }
16}