July 21,2016
Today i have learnt about spinner and progress bar.
Android Spinner
Android Spinner is like the combox box of AWT or Swing. It can be used to display the multiple options to the user in which only one item can be selected by the user.
Android spinner is like the drop down menu with multiple values from which the end user can select only one value.
| Steps | Description |
|---|---|
| 1 | You will use Android studio to create an Android application and name it as AndroidSpinnerExample under a package com.example.spinner. |
| 2 | Modify src/AndroidSpinnerExampleActivity.java file to create a simple list view with items which are showing as spinner items |
| 3 | Modify res/layout/activity_main.xml file to add respective XML code. |
| 4 | No need to define default string constants. Android studio takes care of default string constants at string.xml |
| 5 | Run the application and choose a running android device and install the application on it and verify the results. |
Android ProgressBar
We can display the android progress bar dialog box to display the status of work being done e.g. downloading file, analyzing status of work etc.The ProgressDialog class provides methods to work on progress bar like setProgress(), setMessage(), setProgressStyle(), setMax(), show() etc. The progress range of Progress Dialog is 0 to 10000.
In android there is a class called ProgressDialog that allows you to create progress bar. In order to do this, you need to instantiate an object of this class. Its syntax is.
ProgressDialog progress = new ProgressDialog(this);
Now you can set some properties of this dialog. Such as, its style, its text etc.
progress.setMessage("Downloading Music 🙂 "); progress.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); progress.setIndeterminate(true);