добавлен звук по кнопке

This commit is contained in:
Beluga737 committed 2026-12-03 09:21:36 +07:00
1 parent c80966c192
commit 5c0fff3d04
2 files changed
+14

No files matched your search

@@ -7,8 +7,10 @@ import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import android.media.MediaPlayer
class Settings : AppCompatActivity() {
private var player: MediaPlayer? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
enableEdgeToEdge()
@@ -21,6 +23,18 @@ class Settings : AppCompatActivity() {
findViewById<View>(R.id.buttonOnMain).setOnClickListener {
startActivity(Intent(this, MainActivity::class.java))
finish()
findViewById<View>(R.id.buttonSound).setOnClickListener {
player?.release()
player = MediaPlayer.create(this, R.raw.click)
player?.start()
}
}
}
override fun onDestroy(){
player?.release()
player = null
super.onDestroy()
}
}
Binary file not shown.