android progressBar does not update progress view/drawable

后端 未结 15 2327
悲哀的现实
悲哀的现实 2020-11-28 09:11

two Bars which shows the progress of a game. If the user get points or time is up etc the progressBars should be updated:

private TextView tv;
private Progre         


        
15条回答
  •  旧时难觅i
    2020-11-28 10:00

    I have tried in many ways by calling setProgress in Thread, runOnUiThread, Handler, Runnable. All of them dont work.

    So finally, set value of dialog.setIndeterminate(false); will work.

    Once you set dialog.setIndeterminate(true); the progress WONT UPDATE AT ALL.

    public static ProgressDialog createProgressDialog(Activity activity, int messageID, boolean cancelable) {
        ProgressDialog dialog = new ProgressDialog(activity, R.style.DialogButtonTint);
        dialog.setMessage(activity.getString(messageID));
        dialog.setIndeterminate(false);
        dialog.setMax(100);
        dialog.setSecondaryProgress(0);
        dialog.setProgress(0);
        dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        dialog.setCancelable(cancelable);
        dialog.show();
        return dialog;
    }
    

提交回复
热议问题