Last active
March 20, 2023 04:09
-
-
Save akshaykalola28/a7c313e413fac18a296d1016a9b65526 to your computer and use it in GitHub Desktop.
Kotlin extension functions for show toast with single function.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app.Activity | |
import android.widget.Toast | |
import androidx.annotation.StringRes | |
import androidx.fragment.app.Fragment | |
fun Fragment.toast(message: String) { | |
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show() | |
} | |
fun Fragment.toast(@StringRes message: Int) { | |
Toast.makeText(requireContext(), message, Toast.LENGTH_LONG).show() | |
} | |
fun Activity.toast(message: String) { | |
Toast.makeText(this, message, Toast.LENGTH_LONG).show() | |
} | |
fun Activity.toast(@StringRes message: Int) { | |
Toast.makeText(this, message, Toast.LENGTH_LONG).show() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment