zoukankan      html  css  js  c++  java
  • Android笔记

    消息机制(message, handler)

      message:

        int what;  //用于区分这个消息到底是属于谁来处理的

        int arg1, arg2;  //用于携带int数据类型(相对于setData方法来讲,更省空间)

        Object obj;  //传递引用数据类型(最好用setData方法)

      handler:

        handler处理机制的意义:让新线程周期性地修改UI组件的属性值

        handler的作用:发送与处理信息

        handler的函数:

      • sendEmptyMessage(int what):发送空消息
      • sendMessage(Message msg):立即发送信息
      • void handleMessage(Message msg):处理消息的方法,通常是用于被重写!
      • sendMessageDelayed(Message msg):指定延时多少毫秒后发送信息
      • sendEmptyMessageDelayed(int what,long delayMillis):指定延时多少毫秒后发送空信息
      • final boolean hasMessage(int what):检查消息队列中是否包含what属性为指定值的消息;如果是参数为(int what,Object object):除了判断what属性,还需要判断Object属性是否为指定对象的消息

    bitmap:

    BitmapFactory:

        BitmapFactory.decodeResource(Resource res,int id)  #获取位图资源

          例如:birdBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bird);

    canvas 

      这些函数表示距离的单位是pixel

      获取屏幕尺寸

    width = context.getResources().getDisplayMetrics().widthPixels;
    height = context.getResources().getDisplayMetrics().heightPixels;
    System.out.println(width);
    System.out.println(height);

    View

      View的更新(重绘):

        调用View的成员函数:invalidate() 和 requestLayout()

        invalidate():只会执行onDraw方法,仅View的显示内容发生改变

        requestLayout():只会执行onMeasure方法和onLayout方法,仅View的大小宽高、位置发生改变

    参考:

    • message:https://blog.csdn.net/afdasfggasdf/article/details/83058712
    • handler消息处理机制:http://www.runoob.com/w3cnote/android-tutorial-handler-message.html
    • BitmapFactory.decodeResource():https://blog.csdn.net/Birdmotianlun/article/details/72851626
    • getResource():https://www.cnblogs.com/keyi/p/6282838.html
    • bitmap和BitmapFactory:https://www.cnblogs.com/Free-Thinker/p/6394797.html
    • canvas:https://blog.csdn.net/qq_41405257/article/details/80487997
    • View的更新:https://blog.csdn.net/wangwangli6/article/details/79832294
    • 自定义View:https://www.cnblogs.com/jiayongji/p/5560806.html
  • 相关阅读:
    进程、线程和协程的区别(转)
    IO多路复用机制(转)
    防火墙及其功能(转)
    TCP连接的建立和终止。
    TCP和UDP细致刻画,区别。
    typename T和class T区别与联系
    TCP UDP的详解开始 ----UNIX网络编程
    关于UNIX网络编程的的OSI,1.7章的总结
    UNIX网络编程daytime服务端和客户端的实现过程
    linux shell脚本执行错误:bad substitution
  • 原文地址:https://www.cnblogs.com/sbj123456789/p/10217767.html
Copyright © 2011-2022 走看看