zoukankan      html  css  js  c++  java
  • android view 中各函数的执行顺数

    这个就好像是 activity 的生命周期一样,如果我们要使用自定义的 view,那么就很有必要了解一下 view 的那些能够被重写的函数的执行顺序。废话不多讲,以常用的5个函数为例子,见下文:

     1 package com.example.pulltorefreshtest;
     2 
     3 import android.content.Context;
     4 import android.graphics.Canvas;
     5 import android.util.AttributeSet;
     6 import android.util.Log;
     7 import android.view.View;
     8 
     9 /**
    10  * Created by Administrator on 2015/7/12.
    11  */
    12 public class testView extends View {
    13     public testView(Context context, AttributeSet attrs) {
    14         super(context, attrs);
    15     }
    16 
    17     @Override
    18     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    19         Log.d("------","---onMeasure");
    20         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    21     }
    22 
    23     @Override
    24     protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
    25         Log.d("------","---onLayout");
    26         super.onLayout(changed, left, top, right, bottom);
    27     }
    28 
    29     @Override
    30     protected void onFinishInflate() {
    31         Log.d("------","---onFinanshInflate");
    32         super.onFinishInflate();
    33     }
    34 
    35     @Override
    36     protected void onDraw(Canvas canvas) {
    37         Log.d("------","---onDraw");
    38         super.onDraw(canvas);
    39     }
    40 
    41     @Override
    42     protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    43         Log.d("------","---onSizeChanged");
    44         super.onSizeChanged(w, h, oldw, oldh);
    45     }
    46 }

    运行结果:

    07-12 13:44:45.413  23734-23734/? D/------﹕ ---onFinanshInflate
    07-12 13:44:45.443  23734-23734/? D/------﹕ ---onMeasure
    07-12 13:44:45.493  23734-23734/? D/------﹕ ---onSizeChanged
    07-12 13:44:45.493  23734-23734/? D/------﹕ ---onLayout
    07-12 13:44:45.503  23734-23734/? D/------﹕ ---onMeasure
    07-12 13:44:45.503  23734-23734/? D/------﹕ ---onLayout
    07-12 13:44:45.503  23734-23734/? D/------﹕ ---onDraw
    

      

  • 相关阅读:
    SAP 多料号展BOM
    SAP QM 检验批可用库存回转为待检验库存
    SAP QM UD检验批回转为REL待检验状态
    在ABAP中获取应用程序服务器的IP地址
    SAP连接外部数据库后批量写入数据
    Java调用Axis2用SAP WSDL生成的Stub文件
    用最新的采购信息记录更新采购单的价格——BAPI_PO_CHANGE
    SAP QM——QA01、QA02、QA03屏幕增强
    Java递归实现一、二、三级菜单查询
    ABAP——查询
  • 原文地址:https://www.cnblogs.com/linguanh/p/4640884.html
Copyright © 2011-2022 走看看