zoukankan      html  css  js  c++  java
  • Android sendToTarget

    在使用message进行handler的数据交互的时候不可避免的会使用到message作为数据的载体,可是在使用message的时候有人会直接new一个message,有人会使用handler.obtainMessage(),那么这两种方式那种更好一些呢,或者说应用场景各自是什么呢。以下是我的拙见:

     /**

         * Returns a new {@link android.os.Message Message} from the global message pool. More efficient than

         * creating and allocating new instances. The retrieved message has its handler set to this instance (Message.target == this).

         *  If you don't want that facility, just call Message.obtain() instead.

         */

        public final Message obtainMessage()

        {

            return Message.obtain(this);

        }

    这是android的源代码从凝视上咱们能够看出这样的形式得到的message是先从 global message pool中获取的,大致可类比成1.6之后的String的变量的String pool,而new Message是直接new的,也就是说这两种方式仅仅是在生成对象的形式上不同。

    在分享个imageView在设置图片的时候一般会有两种形式一种是设置src,还有一种是设置background,那么这两种形式有什么不一样的呢:前者是不能拉伸的,而后者是能够随意拉伸的,而且两者可同一时候存在的。

  • 相关阅读:
    tornado与asyncmongo
    Grails/Groovy学习资源
    关于markdown
    Grails一些重要的配置文件
    Grails的目录结构
    Grails中的UrlMapping
    MVC已死,该是用MOVE的时候了
    算法——回溯法
    算法——分支限界法
    C#如何操控FTP
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4516894.html
Copyright © 2011-2022 走看看