Progress unit in ProgressDialog

后端 未结 4 933
隐瞒了意图╮
隐瞒了意图╮ 2020-12-30 10:27

Android\'s ProgressDialog allows you to set the current progress and maximum value as integers. These values are shown in the dialog like this:

3401/1

4条回答
  •  温柔的废话
    2020-12-30 10:53

    Update: setProgressNumberFormat is part of the API since level 11.

    The HEAD of the ProgressDialog source code already includes a public function called setProgressNumberFormat which can be used to set the unit. Unfortunately this function does not seem to be available in the latest Android version. I guess it will be included in a future update.

    In the meantime, copying this implementation of ProgressDialog is the best option. Subclassing ProgressDialog is of no use because all of its members are private and working with view.findViewById(R.id.progress_number) to get the TextView directly is extremely risky, as nothing ensures that the id will be always the same (or that the TextView will always exist).

提交回复
热议问题