如何在这个应用程序中放置一个方法?

时间:2014-03-13 05:34:24

标签: android methods

2 个答案:

答案 0 :(得分:2)

我认为你的意思是"我如何实现if语句"而不是方法。您需要检查音乐是否正在播放,如果是,则将其停止。然后一旦停止,你就可以完成活动。

alertDialog.setPositiveButton("Yes",
new DialogInterface.OnClickListener() {

    public void onClick(DialogInterface dialog, int which) {
        if (mp.isPlaying()){
            mp.stop();
        }
        finish();
    }
});

答案 1 :(得分:1)

在写完int length = mp.getCurrentPosition();

后暂停声音

象 -

int length;
mp.pause();
length = mp.getCurrentPosition();

当用户点击“否”按钮时,请编写以下代码,以便从最近的位置继续播放。

mp.seekTo(length);
mp.start();

对于是按钮@Nood已经回答了。