GreatBritan.java
package com.example.alfabet;
import androidx.appcompat.app.AppCompatActivity;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
public class GreatBritan extends AppCompatActivity {
private MediaPlayer english_vois;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_great_britan);
english_vois = MediaPlayer.create(this, R.raw.englishvois);
Button eng = findViewById(R.id.eng_vois);
eng.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Play_sound_eng();
}
});
ImageView back = (ImageView) findViewById(R.id.back_btn);
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
}
public void Play_sound_eng(){
if (english_vois != null) {
english_vois.start();
}
}
protected void onDestroy() {
super.onDestroy();
if (english_vois != null) {
english_vois.release();
english_vois = null;
}
}
}
|