Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading spinning wheel animation

I'm doing a search and populating a listview with results as they come. On top there's a bar with the text "Search in progress... " I'd like to add a small spinning wheel animation to the bar in the right corner, to show the user that work is being done.

You can see this spinning wheel in the gallery app in the top right corner when thumbnails are being loaded. Also, the same animation is shown in Astro File Manager, when files are being listed in a directory, (again top right corner).

How do I put it there?

like image 413
siamii Avatar asked Mar 14 '11 05:03

siamii


People also ask

What is the loading animation called?

A throbber, also known as a loading icon, is an animated graphical control element used to show that a computer program is performing an action in the background (such as downloading content, conducting intensive calculations or communicating with an external device).


3 Answers

You need to call requestWindowFeature in onCreate before setContentView

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.search_screen);

And Assuming you're using AsyncTask for Populating the list

onPreExecute() will call setProgressBarIndeterminateVisibility(true);

onPostExecute() will call setProgressBarIndeterminateVisibility(false);

like image 93
st0le Avatar answered Oct 20 '22 09:10

st0le


i did spinning progress bar in my application. Hope this will helps you.

progDailog = ProgressDialog.show(this, "Progress_bar or give anything you want",
            "Give message like ....please wait....", true);
    new Thread() {
        public void run() {
            try {
                // sleep the thread, whatever time you want. 
                sleep(2000);
            } catch (Exception e) {
            }
            progDailog.dismiss();
        }
    }.start();

if you have still doubts, pls let me know.

like image 13
RAAAAM Avatar answered Oct 20 '22 09:10

RAAAAM


        ProgressDialog dialog = new ProgressDialog(youravtivity.this);
        dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        dialog.setMessage("Loading. Please wait...");
        dialog.setIndeterminate(true);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();
like image 6
Abhi Avatar answered Oct 20 '22 08:10

Abhi