简体   繁体   English

停止进度条旋转并分散显示输入的结果?

[英]Stop the progress bar from spinning and diisplaying the results entered?

I am creating an app that will get numbers between 0-100 from the user, then getting the average and displaying it in a progress bar. 我正在创建一个应用程序,它将从用户那里获取0-100之间的数字,然后获取平均值并将其显示在进度栏中。 For example the user enters 100, 80 and 75 the total is 255 and the average is 85 so i would like the progress bar to fill 3/4 of the circle and stop. 例如,用户输入100、80和75,总计为255,平均值为85,因此我希望进度条填充圆圈的3/4并停止。 At the moment the progress bar keeps spinning in circles and doesn't stop at the location I want even when I specify it with .setProgress(85) . 目前,进度条一直在旋转,并且即使在我使用.setProgress(85)指定时,它也不会停在我想要的位置。 Could anybody help me out I'm quite stuck here's my code: 有人可以帮我解决这个问题吗?

xml: xml:

    <ProgressBar
    android:id="@+id/mProgressBar"
    android:layout_width="150dp"
    android:layout_height="150dp"
    android:layout_centerInParent="true"
    android:rotation="-90"/>

java: Java的

    mProgressBar = (ProgressBar) findViewById(R.id.mProgressBar);
    mProgressBar = new ProgressBar(ActivityA.this, null,    android.R.attr.progressBarStyleLarge);
    mProgressBar.setProgress(30);
    mProgressBar.setMax(100);

You cannot do it with a simple progress bar. 您不能使用简单的进度条来做到这一点。

Please take a look to this github or you might want to use a progress Dialog instead. 请查看此github,或者您可能想使用进度对话框。 Here is a good tutorial , easy to follow. 这是一个很好的教程 ,易于理解。

Ex : 例如:

    barProgressDialog = new ProgressDialog(this);
    barProgressDialog.setTitle("Downloading Image ...");
    barProgressDialog.setMessage("Download in progress ...");
    barProgressDialog.setProgressStyle(barProgressDialog.STYLE_HORIZONTAL);
    barProgressDialog.setProgress(0);
    barProgressDialog.setMax(20);
    barProgressDialog.show();

This is pretty much what you want to do. 这几乎就是您想要做的。

Hope it helps ! 希望能帮助到你 !

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM