Sunteți pe pagina 1din 3

Contact Us Disclaimer Privacy Policy

Home Tutorials Tips and Tricks Apps Courses

HOME → TUTORIALS Search … Search

Progress Dialog deprecated, Alternative is GET MORE STUFF

SpotsDialog Example in Android Subscribe to our mailing list and get


interesting stuff and updates to your
Sama Gyani — September 10, 2017 in Tutorials • add comment email inbox.

Progress Dialog deprecated in Android Oreo 8 i.e., SDK 26. Now it’s time to find some alternative to
Enter your email here
the progress dialog. After some google search, I found this simple progress dialog called SpotsDialog
from wasabeef android ui library.

SIGN UP NOW
Similar to progress dialog, we need not define an xml widget for SpotDialog. SpotsDialog is clean and
we respect your privacy and take protecting it
gives fluid user experience.
seriously

In short, we can expect this an alternative to progress dialog in android.

FOLLOW US ON
We implemented this in our project, here we will example on how to implement this progress dialog
alternative. Follow my blog with Bloglovin

Let us start the implementation.

In app level build.gradle, place the Spots Dialog library and sync the project.

1 compile 'com.github.d-max:spots-dialog:0.7@aar'

This SpotsDialog is inherited from Alert Dialog, so initially, we create a variable of AlertDialog as class
instance.

1 AlertDialog dialog;
2 private static final int DIALOG_SHOW_TIME = 5000;

We have also declared an int variable to show the spots dialog for that duration of time.

In onCreate() method, we declare spots dialog as follows

1 dialog = new SpotsDialog(this);

To show the dialog, we should use show() method.

1 dialog.show();

To dismiss the dialog, we should use dismiss() method.

1 dialog.dismiss();

The complete java file for this example will like below
1 import android.app.AlertDialog;
2 import android.os.Bundle;
3 import android.os.Handler;
4 import android.support.v7.app.AppCompatActivity;
5  
6 import dmax.dialog.SpotsDialog;
7  
8 public class MainActivity extends AppCompatActivity {
9  
10     AlertDialog dialog;
11     private static final int DIALOG_SHOW_TIME = 5000;
12  
13     @Override
14     protected void onCreate(Bundle savedInstanceState) {
15         super.onCreate(savedInstanceState);
16         setContentView(R.layout.activity_main);
17  
18         dialog = new SpotsDialog(this);
19         dialog.show();
20  
21         new Handler().postDelayed(new Runnable() {
22             @Override
23             public void run() {
24                 dialog.dismiss();
25             }
26         },DIALOG_SHOW_TIME);
27  
28     }
29 }

To style this spots dialog, we can define a custom style in the styles.xml file and pass it to the Spots
Dialog constructor.

1 <style name="Custom" parent="android:Theme.DeviceDefault.Dialog">


2         <item name="DialogTitleAppearance">@android:style/TextAppearance.Medium</item>
3         <item name="DialogTitleText">This is Spots Dialog</item>
4         <item name="DialogSpotColor">@color/colorPrimary</item>
5         <item name="DialogSpotCount">4</item>
6         <item name="android:textColor">@android:color/black</item>
7         <item name="android:background">@android:color/white</item>
8     </style>

We can put custom title, spot color, and spot count for spots dialog.

Pass the style name to the Spots Dialog constructor to see the effect.

1 dialog = new SpotsDialog(this,R.style.Custom);

We do not need to define anything in layout, leave it as it is, build the project and run the app to see the
output.

progress dialog alternative, spots dialog in android example

This is all about Spots Dialog, we can use this as an alternative to progress dialog, which is deprecated
now in SDK 26.
Download this project

This content is locked!


Please support us, use one of the buttons below to unlock the content.

 like
Like 4  tweet
Tweet error+

android development progress dialog alternative progress dialog alternative example in android
progress dialog alternative spots dialog

You May Also Like

Custom Font in Android Create Material Design


Force Update Android Android Rate Us Dialog Icon for Android App in
Example in Android
App When New Version Example Android Studio
Studio
Available Example

About the Author: Sama Gyani


I am Computer Science Graduate. I turn my interests into posts here.

Leave a Reply
Your email address will not be published. Required fields are marked *

Comment

Name * Email * Website

Post Comment

© 2018 DroidBlogger - Android Tutorials and Tricks - Theme by HappyThemes Home Tutorials Tips and Tricks Apps Courses

S-ar putea să vă placă și