zoukankan      html  css  js  c++  java
  • android源代码分析 android toast使用具体解释 toast自己定义

    在安卓开发过程中。toast使我们常常使用的一个类。当我们须要向用户传达一些信息,可是不须要和用户交互时,该方式就是一种十分恰当的途径。

    我们习惯了这样使用toast:Toast.makeText(Context context, String info, int duration).show();该方法是

    系统为我们提供的一个方便的创建toast对象的静态方法,其内部依旧是调用toast的相关方法完毕。以下

    就从其源代码对该类的实现做一个分析

    在toast类中,最重要的用于显示该toast的show方法调用了service.enqueueToast(pkg, tn, mDuration);也就是说

    系统为我们维持了一个toast队列,这也是为什么两个toast不会同一时候显示的原因。该方法将一个toast入队,显示则由系统维持显示的时机。

     private static INotificationManager sService;


        static private INotificationManager getService() {
            if (sService != null) {
                return sService;
            }
            sService = INotificationManager.Stub.asInterface(ServiceManager.getService("notification"));
            return sService;
        }
    该服务sService就是系统用于维护toast的服务。

    在toast内部又一个静态私有类TN,该类是toast的主要实现,该类完毕了toast视图的创建,等等


    fa

  • 相关阅读:
    图论:带花树算法-一般图最大匹配
    图论&数学:最小平均值环
    图论:朱刘算法
    图论&动态规划:虚树
    图论:动态点分治
    图论:平面图的对偶图
    图论:DFS序
    打开页面时,所有节点展开(ztree)
    Vue 常用记录
    Vue v-if and v-for
  • 原文地址:https://www.cnblogs.com/mthoutai/p/6775485.html
Copyright © 2011-2022 走看看