-
-
Save e4basil/87c53d3f1c643b184f492dc692c8b625 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