CustomToast-Kotlin - Types of Toast Style ❤️
1. Info Toasta | 2. Success Toasta | 3. Warning Toasta | 4. Error Toasta | 5. Basic Toasta |
---|---|---|---|---|
A Beautiful CustomToasta in Android using Kotlin.
1. Info Toasta
2. Success Toasta
3. Warning Toasta
4. Error Toasta
5. Basic Toasta
1. LONG_DURATION // 4 Seconds
2. SHORT_DURATION // 2 Seconds
fun makeInfoToast() {
makeToast(this, "This is an Info Toast Message").show()
// Toasta.makeToast(this, "This is an Info Toast Message").show()
}
fun makeSuccessToasta() {
makeToast(
this,
"This is a Success Toast Message",
Toasta.CUSTOM_DURATION_SHORT,
Toasta.CUSTOM_TYPE_SUCCESS,
Toasta.CUSTOM_GRAVITY_TOP
).show()
}
fun makeWarningToasta() {
Toasta.makeToast(
this,
"This is a Warning Toast Message",
Toasta.CUSTOM_DURATION_SHORT,
Toasta.CUSTOM_TYPE_WARNING,
Toasta.CUSTOM_GRAVITY_CENTER
).show()
}
fun makeErrorToasta() {
makeToast(
this,
"This is an Error Toast Message",
Toasta.CUSTOM_DURATION_LONG,
Toasta.CUSTOM_TYPE_ERROR
).show()
}
fun makeToastabasic() {
Toast.makeText(this, "This is an Basic Toast Message", Toast.LENGTH_SHORT).show()
}
fun btnView() {
button.setOnClickListener {
makeInfoToasta()
}
button2.setOnClickListener {
makeSuccessToasta()
}
button3.setOnClickListener {
makeWarningToasta()
}
button4.setOnClickListener {
makeErrorToasta()
}
button5.setOnClickListener {
makeToastabasic()
}
}