wormhit
wormhit

Reputation: 3827

How can I set my own ProgressDialog loading image?

I have animated gif image and when i try to use it in ProgressDialog it wont show.

    ProgressDialog dialog = new ProgressDialog(this);
    dialog.setIcon(R.drawable.loading);
    dialog.setTitle("Loading");
    dialog.setMessage("Please wait...");
    dialog.show();

What I`m doing wrong? How can I set my own loading image?

Upvotes: 1

Views: 8080

Answers (3)

Maybe it's too late,but i have same question with you. And then i find the solution in this GitHub Code Repository And then here what i'am doing

  1. Android can't be automatically load gif so you must split your gif image into images. You can use this site to split your Gif. Copy split gif image into your drawable folder.
  2. Create custom progress dialog and custom layout.
  3. Create custom progress animation and then edit soruce image. and then change duration like what you want.
  4. Change your code into like this

    ProgressDialog dialog = new MyCustomProgressDialog.ctor(this); dialog.show();

  5. and than your loading image has been change.

That code just show gif image, if you want settitle and setimage just change custom progress dialog and custom layout

Upvotes: 4

Dinesh Sharma
Dinesh Sharma

Reputation: 11571

You can use custom dialog instead of using the default ProgressDialog. Set images according to your need.

Upvotes: 0

Hamdullah shah
Hamdullah shah

Reputation: 654

The default loading image is not a gif image it's a combination of two images and then animating it around. view the source code it may help you in res.drawable/progress_large.xml of android.

Upvotes: 0

Related Questions