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(){ @Overridepublic 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空间,希望可以帮助到你!!!

浙公网安备 33010602011771号