APP一般Toast主要有三种,正常的、成功的、错误的。
分别为每种设计一种布局,传入提示的 text 就可以了,同时限制了相同 text 的Toast 2 秒内不能重复提示!
package com.youthmba.ymbaandroid.appbiz.basics
import android.content.Context
import android.text.TextUtils
import android.view.Gravity.CENTER
import android.view.LayoutInflater
import android.widget.TextView
import android.widget.Toast
import com.youthmba.ymbaandroid.R
import com.youthmba.ymbaandroid.appbiz.Application
public class NewToastUtils {
companion object {
var lastToastTime = 0L
var lastToastString = ""
@JvmStatic
fun toastNormal(text:String?) {
if(!TextUtils.isEmpty(text)){
toast(text!!,R.layout.toast_normal)
}
}
@JvmStatic
fun toastSuccess(text:String?) {
if(!TextUtils.isEmpty(text)){
toast(text!!,R.layout.toast_success)
}
}
@JvmStati