Android ProgressBar: progress bar control

When the application runs in the background, you can use the progress bar to feed back the current progress information to the user. The progress bar is used to display the running status of the current application, how many functions have been completed, etc. The Android SDK provides two styles of progress bars: a circular progress bar and a horizontal progress bar. The circular progress bar is divided into three types: large, medium and small. The progress bar is essentially an integer that shows the proportion of the current integer value in a specific range. The following is a simple example to explain how to use the progressbar component. Add a button named progressbardemo in the layout file main.xml of the project widgetdemo to start processbaractivity. Add the following code in main.xml:

Click button and start processbaractivity. The code is as follows:

At the same time, declare the activity in the androidmanifest.xml file:

<activity android:name=".ProcessBarActivity"></activity>

The running effect of processbaractivity is shown in Figure 1.

The layout file used by processbaractivity is processbar.xml, which is as follows:

In this layout, there are three types of circular progress bars: small, medium and large, and a horizontal bar progress bar. Generally, developers will not specify the progress for the circular progress bar. The circular progress bar only shows the operation effect, but does not reflect the actual progress. The bar progress bar is different. The developer will specify the maximum value for the bar progress bar and the method to obtain the current value of the bar progress bar. In this example, the maximum value of the bar progress bar is 100. The code of processbaractivity.java is as follows:

Processbaractivity processes the horizontal progress bar. First, the maximum value of the horizontal progress bar is obtained, and then a thread is started to control the value of the progress bar, starting from 0 and increasing by 1 every 15 milliseconds.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>