Pro-Tutr
Add Stylish Toast In Your App Using simple Library - Printable Version

+- Pro-Tutr (http://protutr.com)
+-- Forum: Programming Languages (http://protutr.com/forumdisplay.php?fid=3)
+--- Forum: Android (http://protutr.com/forumdisplay.php?fid=5)
+--- Thread: Add Stylish Toast In Your App Using simple Library (/showthread.php?tid=987)



Add Stylish Toast In Your App Using simple Library - Ravishankar Chavare - 02-03-2018

Demo:




step 1:create your project with name StylishToasts

Step 2: Now go to build.gradle(project level) and add following code

Code:
allprojects {
    repositories {
        maven { url "https://jitpack.io" }
    }
}


Step 3:open build.gradle(App level) and compile following third party library
Code:
    compile 'com.github.GrenderG:Toasty:1.2.8'

now click on Sync now wait some time to sync this library into your project

Step 4:Now You can use Toasty in the Folowing Way

To display an error Toast:

Code:
Toasty.error(yourContext, "This is an error toast.", Toast.LENGTH_SHORT, true).show();

To display a success Toast:

Code:
Toasty.success(yourContext, "Success!", Toast.LENGTH_SHORT, true).show();

To display an info Toast:

Code:
Toasty.info(yourContext, "Here is some info for you.", Toast.LENGTH_SHORT, true).show();

To display a warning Toast:

Code:
Toasty.warning(yourContext, "Caution:Dont misspell.", Toast.LENGTH_SHORT, true).show();

To display the usual Toast:

Code:
Toasty.normal(yourContext, "Normal toast w/o icon").show();

To display the usual Toast with icon:

Code:
Toasty.normal(yourContext, "Normal toast w/ icon", yourIconDrawable).show();

You can also create your custom Toasts with the custom() method:

Code:
Toasty.custom(yourContext, "I'm a custom Toast", yourIconDrawable, tintColor, duration, withIcon, 
shouldTint).show();

//yourIconDrawable-R.drawable.iconpath
//tintColor-getResources().getColor(R.color.colorPrimary)
//withIcon-true or false
//shouldTint-true or false

Github Project Link Here