如果用户单击它,则如何禁用媒体播放器中的恢复按钮

时间:2013-10-07 11:02:32

标签: android

我在Media Player中使用此功能生成警报对话框,并在用户恢复视频时对其进行响应

  setPositiveButton-->"Start Over"
  setNegitiveButton-->"Resume"   

        public abstract void onClick (DialogInterface dialog, int which){
          //what i need is disable the "RESUME" if user clicked it once...

我在这里粘贴你的全部功能请修改它......

   private void showResumeDialog(Context context, final int bookmark) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(R.string.resume_playing_title);
    builder.setMessage(String.format(
            context.getString(R.string.resume_playing_message),
            GalleryUtils.formatDuration(context, bookmark / 1000)));
    builder.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            onCompletion();
        }
    });
    builder.setPositiveButton(
            R.string.resume_playing_resume, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            mVideoView.seekTo(bookmark);
            startVideo();
        }
    });
    builder.setNegativeButton(
            R.string.resume_playing_restart, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            startVideo();
        }
    });
    builder.show();
}

1 个答案:

答案 0 :(得分:0)

检查这是您的代码

Int flag=0;
private void showResumeDialog(Context context, final int bookmark) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle(R.string.resume_playing_title);
        builder.setMessage(String.format(
            context.getString(R.string.resume_playing_message),
            GalleryUtils.formatDuration(context, bookmark / 1000)));
    builder.setOnCancelListener(new OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            onCompletion();
        }
    });
    builder.setPositiveButton(
            R.string.resume_playing_resume, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {

            flag++;
            If(flag>1)
            {
                mVideoView.seekTo(bookmark);
                startVideo();
            }else{

                //Do Nothing
            }
        }
    });
    builder.setNegativeButton(
            R.string.resume_playing_restart, new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            startVideo();
        }
    });
    builder.show();
}

祝你好运......