Kotlin's tips for multiple showToast functions A function calls to a Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

In the code written: multiple Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

	......
Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
	......
Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
	......
Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
	......
Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
	......
Toast.makeText(this, "", Toast.LENGTH_SHORT).show()
	......

It seems to be troublesome, you can write: a function of multiple showToast functions is called to a Toast.makeText(this, "", Toast.LENGTH_SHORT).show()

	......
showToast(mErrorMsg)
	......
showToast(mErrorMsg)
	......
showToast(mErrorMsg)
	......
showToast(mErrorMsg)
	......
showToast(mErrorMsg)
	......
	......
	......
private fun showToast(msg: String) {
    
    
    Toast.makeText(this, msg, Toast.LENGTH_SHORT).show()
}

Guess you like

Origin blog.csdn.net/qq_35091074/article/details/123684752