当前位置: 首页 > news >正文

天津外贸网站建设公司英雄联盟世界排名

天津外贸网站建设公司,英雄联盟世界排名,可以在网上接网站做的网址,专注合肥网站推广文章目录1、使用上1.1 Intent 方式1.2 Bundle 方式2、为什么 Bundle 使用 ArrayMap 而不是 Hashmap 实现呢?1、使用上 1.1 Intent 方式 举例:将数据从页面 A 传递到 B,然后再传递到 CA 页面: Intent intentnew Intent(MainActi…

文章目录

      • 1、使用上
        • 1.1 Intent 方式
        • 1.2 Bundle 方式
      • 2、为什么 Bundle 使用 ArrayMap 而不是 Hashmap 实现呢?

1、使用上

1.1 Intent 方式

  • 举例:将数据从页面 A 传递到 B,然后再传递到 C
  • A 页面:
Intent intent=new Intent(MainActivity.this,BActivity.class);
intent.putExtra("String","MainActivity中的值");
intent.putExtra("int",11);
startActivity(intent);
  • B 页面:
// 接收
Intent intent = getIntent();
string = intent.getStringExtra("String");
key = intent.getIntExtra("int",0);// 发送
Intent intent=new Intent(BActivity.this,CActivity.class);
intent.putExtra("String1",string);
intent.putExtra("int1",key);
intent.putExtra("boolean",true);
startActivity(intent);
  • 在 B 页面需要将数据一条条取出来,再一条条发送给 C

1.2 Bundle 方式

  • A 页面:
Intent intent = new Intent(MainActivity.this, BActivity.class);
Bundle bundle = new Bundle();
bundle.putString("String","MainActivity中的值");
bundle.putInt("int",11);
intent.putExtra("bundle",bundle);
startActivity(intent);
  • B 页面:
// 接收
Intent intent = getIntent();
bundle=intent.getBundleExtra("bundle");// 发送
Intent intent=new Intent(BActivity.this,CActivity.class);
//可以传给CActivity额外的值
bundle.putBoolean("boolean",true);
intent.putExtra("bundle1",bundle);
startActivity(intent);
  • 可以直接对 Bundle 进行操作。但是 Bundle 需要借助 Intent 完成数据触动你
  • ++Bundle 旨在存储数据,Intent 旨在传值++

2、为什么 Bundle 使用 ArrayMap 而不是 Hashmap 实现呢?

  • Bundle 内部由 ArrayMap 实现。ArrayMap 底层是两个数组,一个 Int 数组存储 key 对应的 hash 值,另一个数组存储 key 和 value,key 在 index*2 位置,value 在 index*2+1 位置。每次插入时,根据 key 的 hash 值,利用二分查找,去寻找 key 在 Int 数组中的下标位置 index,如果出现了 hash 冲突,从目标点向两头遍历,直到找到正确的 index。二份查找法只适合小数据量操作,如果数据量比较大,性能将退化。而 Bundle 的场景大多数为小数据量,故使用 ArrayMap 更合适。

  • 其次,HashMap 使用 Serializable 进行系列化,Bundle 使用 Parcelable 进行系列化。在 Android 平台,更推荐使用 Parcelable 实现序列化,开销更小,能更快的进行书序的序列化和反序列化。

  • 相关文章
    ArrayMap 源码解析
    HashMap 源码解析
    Serializable 和 Parcelable

http://www.mmbaike.com/news/46874.html

相关文章:

  • phpcms v9怎么做网站网站域名备案信息查询
  • 和外国人做ic生意的网站西安关键词优化服务
  • vs网站开发参考文献百度app下载官方免费最新版
  • 网站访问速度 云主机怎样免费制作网页
  • 对于新公司如何让其做网站推广营销策略ppt模板
  • 用vue做商城网站常用的js最吸引人的引流话术
  • 百度怎么对网站处罚企业如何进行宣传和推广
  • 重庆网站设计哪家公司好西安百度百科
  • 免费制作的企业网站营销技巧五步推销法
  • 泰州做网站的公司网站推广策划案
  • 政府网站新媒体平台建设seo推广服务哪家好
  • 玉林住房和城乡规划建设委员会网站谷歌推广和seo
  • 勾线外包网站百度客服电话人工服务热线电话
  • 网站开发服务公司怎么给产品做网络推广
  • 监测网站定制seo公司优化方案
  • 做网站的咋挣钱小红书seo是什么
  • 做网站哪一家公司好天津网站排名提升
  • 微信网站开发 js框架免费网站搭建
  • 口碑好的大良网站建设百度技术培训中心
  • jsp动态网站开发基础与上机指导深圳seo优化推广公司
  • 外贸建站用什么服务器易观数据
  • 建个公司网站多少钱广州最新疫情
  • wordpress 的主题汕头seo建站
  • 手机网站模板 网址b站推广网站mmm
  • 学做网站能赚钱吗搜索引擎网站排名优化方案
  • 网站建设及推广好做吗恢复原来的百度
  • 网站开发拖延交货算诈骗吗seo排名优化公司哪家好
  • 烦恼可以做网站吗怎么建立自己的网页
  • 网站建设公司市场开发方案知识搜索引擎
  • 大作设计网站是中国的吗站长之家网站查询