Skip to content

sad-adnan/customToast

Repository files navigation

CustomToast

Android Library to show Custom Toast message

Support:

sad_adnan



[Please don't use v1.2 or 1.2 they are deleted and not meant for production , they are actually not usable]

To get a Git project into your build:

Step 1. Add the JitPack repository to your build file

gradle

Add it in your root build.gradle at the end of repositories:

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

Step 2. Add the dependency

dependencies {
        implementation 'com.github.sad-adnan:customToast:v1.3'
}

Use Case

From version 1.1 you have default value of toast as Toast>LENGTH_SHORT so you can just give one parameter (2nd one) less, if you need short length.

CustomToast.ShowSuccessToast(MainActivity.this,"Congratulations"); // 2nd parameter DEFAULT value false --> Toast.LENGTH_SHORT

you can show a success message by using below code :

    CustomToast.ShowSuccessToast(MainActivity.this,false,"Congratulations"); // 2nd parameter true --> Toast.LENGTH_LONG  , false --> Toast.LENGTH_SHORT

you can show a Error message by using below code :

    CustomToast.ShowErrorToast(MainActivity.this,false,"We are extremely sorry."); // 2nd parameter true --> Toast.LENGTH_LONG  , false --> Toast.LENGTH_SHORT

you can show a Info message by using below code :

    CustomToast.ShowInfoToast(MainActivity.this,false,"We have updated your status."); // 2nd parameter true --> Toast.LENGTH_LONG  , false --> Toast.LENGTH_SHORT

you can show a custom Toast message with icon and message by using below code :

you have to pass drawable resource id (R.drawable.yourdrawable) and color id (R.color.yourcolor) in 4th and 5th Parameter respectively
    CustomToast.showToastWithCustomDrawableAndBG(MainActivity.this,false,"Custom Icon",R.drawable.ic_baseline_auto_delete_24,R.color.toastColor); // 2nd parameter true --> Toast.LENGTH_LONG  , false --> Toast.LENGTH_SHORT
    CustomToast.showToastWithoutIcon(MainActivity.this,false,"Without icon",R.color.toastColor2); // this method will only show text, without any drawable , 2nd parameter true --> Toast.LENGTH_LONG  , false --> Toast.LENGTH_SHORT

About

Android Library to show Custom Toast message

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages