Loading Spinner in android
The progress bar comes in two shapes. Loading bar and Loading Spinner. In this chapter we will discuss spinner.
Spinner is used to display progress of those tasks whose total time of completion is unknown. In order to use that, you just need to define it in the xml like this.
<ProgressBar android:id="@+id/progressBar1" style="?android:attr/progressBarStyleLarge" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" />
After defining it in xml, you have to get its reference in java file through ProgressBar class. Its syntax is given below −
private ProgressBar spinner; spinner = (ProgressBar)findViewById(R.id.progressBar1);
After that you can make its disappear , and bring it back when needed through setVisibility Method. Its syntax is given below −
Apart from these Methods, there are other methods defined in the ProgressBar class , that you can use to handle spinner more effectively.
|Sr.No||Method & description|
Indicate whether this progress bar is in indeterminate mode
Cause an invalidate to happen on a subsequent cycle through the event loop
Change the indeterminate mode for this progress bar
Invalidates the specified Drawable
Increase the progress bar's secondary progress by the specified amount
Get the drawable used to draw the progress bar in progress mode