Untitled

mail@pastecode.io avatar
unknown
plain_text
10 months ago
610 B
5
Indexable
Never
 fun showtoast(distance: String,chk:Boolean){
        val inflater = LayoutInflater.from(this)
        val layout = inflater.inflate(R.layout.custom_toast, null)
        val text = layout.findViewById(R.id.toast_text) as TextView
        text.text = distance // Set your message here
       pointtoast?.cancel()
        pointtoast = Toast(this)
        pointtoast!!.setGravity(Gravity.TOP,0,300)
        pointtoast!!.duration = Toast.LENGTH_SHORT
        pointtoast!!.view = layout
        if(chk){
            pointtoast!!.show()
        }else{
            pointtoast!!.cancel()
        }
    }