| | |
| | | package cn.sinata.xldutils.utils |
| | | |
| | | import android.content.Context |
| | | import android.view.Gravity |
| | | import android.view.LayoutInflater |
| | | import android.widget.TextView |
| | | import android.widget.Toast |
| | |
| | | fun Context.myToast(message: CharSequence,longTime:Boolean=false) { |
| | | val toast = Toast(this) |
| | | toast.duration = if (longTime)Toast.LENGTH_LONG else Toast.LENGTH_SHORT |
| | | toast.setGravity(Gravity.CENTER, 0, 0) |
| | | // toast.setGravity(Gravity.CENTER, 0, 0) |
| | | val toastLayout = LayoutInflater.from(this).inflate(R.layout.layout_center_toast, null) |
| | | val txtToast: TextView = toastLayout.findViewById(R.id.txt_toast) |
| | | txtToast.text = message |