当前位置: 首页 > article >正文

Android 开发中自定义吐司(二)

上一篇文章主要分享了Android 开发中自定义Toast-CSDN博客    这篇文章主要分享另一种写法也可以实现自定义布局+设置不同的时长:

自定义吐司的类:
public class CustomToast extends Toast {

    private static int mduration;

    public CustomToast(Context context) {
        super(context);
    }

    public static CustomToast makeText(Context context, CharSequence text, int duration,String content) {
        LayoutInflater inflater = LayoutInflater.from(context);
        View customToastView = inflater.inflate(R.layout.custom_toast, null);
        TextView toastTextView = customToastView.findViewById(R.id.toast_text);
        mduration = duration;
        if (content.contentEquals("3")){
            toastTextView.setBackgroundResource(R.drawable.orange_bg18);
            toastTextView.setText(text);
//          toastTextViewnt.setText("报告可能生成失败,请稍后前往报告列表查看&#

http://www.kler.cn/a/452782.html

相关文章:

  • Redis基础(1)--基本全局指令与架构
  • Charles安装证书过程(手机)
  • CSS系列(35)-- Subgrid详解
  • uni-app开发订单详情页面
  • Vue3知识弥补漏洞——性能优化篇
  • SSH无法启动问题:OpenSSL version mismatch. Built against 30000070, you have 30200020
  • np.triu:NumPy中提取上三角矩阵的利器
  • APP投放的归因框架设计
  • 枚举与lambda表达式,枚举实现单例模式为什么是安全的,lambda表达式与函数式接口的小九九~
  • python闭包详解
  • 2024年第十一期 | CCF ODC《开源战略动态月报》
  • 使用Python开发高级游戏:实现一个3D射击游戏
  • UE5仿漫威争锋灵蝶冲刺技能
  • ElasticSearch 的工作原理
  • Springboot + vue3 实现大文件上传方案:秒传、断点续传、分片上传、前端异步上传
  • 医药垃圾分类管理系统|Java|SSM|JSP|
  • Intent--组件通信
  • 华为认证考试模拟题测试题库(含答案解析)
  • STM32-笔记10-手写延时函数(SysTick)
  • nacos-服务发现注册