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,那么这两种形式有什么不一样的呢:前者是不能拉伸的,而后者是能够随意拉伸的,而且两者可同一时候存在的。

  • 相关阅读:
    Python strip()方法介绍
    python实现猜拳游戏
    Shopping cart program--python
    转置矩阵的行和列
    Oldman python of full stack-Day2
    根据输入生成二维码
    python 中设置字体/背景颜色
    如何用Notepad++运行python程序
    web前端【第十篇】jQuery基本语法
    web前端【第九篇】JS的DOM对象三
  • 原文地址:https://www.cnblogs.com/gcczhongduan/p/4516894.html
Copyright © 2011-2022 走看看