lmw
2025-01-10 601f14db94013373df700e007095f7f2f5ecbe24
xldutils-kotlin/src/main/java/cn/sinata/xldutils/utils/Extends.kt
@@ -9,6 +9,7 @@
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import cn.sinata.xldutils.R
import org.jetbrains.anko.dip
/**
 * 扩展方法:允许DialogFragment使用 commitAllowingStateLoss 弹窗
@@ -31,3 +32,14 @@
    toast.view = toastLayout
    toast.show()
}
fun Context.whiteToast(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, dip(100))
    val toastLayout = LayoutInflater.from(this).inflate(R.layout.layout_white_toast, null)
    val txtToast: TextView = toastLayout.findViewById(R.id.txt_toast)
    txtToast.text = message
    toast.view = toastLayout
    toast.show()
}