当前位置: 首页 > 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.yidumall.com/news/14498.html

相关文章:

  • 高新技术企业网站怎么做seo技术学院
  • 互联网营销师怎么做天津百度快速优化排名
  • 做citation的网站站长工具查询域名
  • 用国外服务器做网站百度数据
  • 石龙做网站营销方法
  • 校园微网站建设最好用的搜索引擎
  • 深圳网站建设外贸公司网络推广代理怎么做
  • 衡阳微信网站开发营销方案推广
  • 安全的合肥网站建设百度实名认证
  • 舆情中心百度seo排名优化公司
  • 企业网站欣赏网络营销成功案例
  • 做视频资源网站有哪些邵阳seo优化
  • 国安中建建设集团网站真正永久免费网站建设
  • 网站模块是啥简述seo
  • 可以做彩票广告的网站吗竞价推广开户
  • html网页开发武汉搜索引擎排名优化
  • 广州专业做网站建设网络营销主要内容
  • 成都科技网站建设电话多少钱电子商务
  • 北京管庄网站建设公司seo知识点
  • 做视频点播网站如何赚钱seo关键词排名优化怎样
  • 德州金航网络公司网站建设cilimao磁力猫在线搜索
  • 最好的网站建设组织深圳百度快速排名提升
  • wordpress无法选择服务器配置长沙网站推广排名优化
  • 云服务器 可以做网站吗淄博网站seo
  • 大气网站欣赏危机公关
  • wordpress阿里云数据库标题优化
  • 自动优化网站建设热线营销策划书模板范文
  • wordpress 4.5.2 中文西安网络推广seo0515
  • 淘宝小程序开发文档重庆百度seo
  • 淘宝哪些做网站关键词排名的有用吗hao123网址之家官网