zoukankan      html  css  js  c++  java
  • android中handler和bundle有什么区别和联系 都是用来传递消息吗都是信息的载体吗

    1、handler是消息处理者,通常重写Handler的handleMessage()方法,在方法中处理接收到的不同消息,例如:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Handler mHandler=new Handler(){
          
    @Override
    public void handleMessage(Message msg) {
    switch (msg.what) {
    case 110:
    progressValue += msg.arg1;
    pb_horizontal.setProgress(progressValue);
    Log.d("progressValue-------------->", progressValue+"");
    break;
     
    }
    }
    }

    2、Bundle是一个载体,可以存放基本数据类型、对象等内容,好比是一辆货车,可以装各种东西,然后运到需要的地方,例如:

    1
    2
    3
    4
    5
    6
    7
    Bundle mBundle=new Bundle();
    mBundle.putString("name","zhaolinit");
    mBundle.putInt("number",123456);
    mBundle.putBoolean("flag",false);
    //然后,放到Intent对象中
    Intent mIntent=new Intent();
    mIntent.putExtras(mBundle);

    3、关于Handler和Bundle的更多介绍,可以百度:TeachCourse空间,希望可以帮助到你!!!

  • 相关阅读:
    vim操作
    git命令
    Python笔记(二)
    python笔记
    gdb笔记 ---《Linux.C编程一站式学习》
    python笔记——dict和set
    echo $?
    FastDFS与Nginx环境配置
    Nginx依赖库安装
    mixin多继承包装过程
  • 原文地址:https://www.cnblogs.com/dazhao/p/5309591.html
Copyright © 2011-2022 走看看