Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Contributor: Ravishankar ChavareAdd Stylish Toast In Your App Using simple Library
#1
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
Reply


Messages In This Thread
Add Stylish Toast In Your App Using simple Library - by Ravishankar Chavare - 02-03-2018, 06:26 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)