0

我曾在媒体播放器中使用此功能来生成警报对话框并在用户恢复视频时对其做出响应

  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();
}
4

1 回答 1

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();
}

祝你好运...

于 2013-10-07T11:09:05.433 回答