📜  在按钮单击时播放声音 android studio - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:34.644000             🧑  作者: Mango

代码示例1
Button one = (Button) this.findViewById(R.id.button1);
final MediaPlayer mp = MediaPlayer.create(this, R.raw.soho);
one.setOnClickListener(new OnClickListener(){

    public void onClick(View v) {
        mp.start();
    }
});