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

网站建设网站多少钱网站开发公司

网站建设网站多少钱,网站开发公司,后缀int网站,响应式网站 手机版文章目录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.fp688.cn/news/143240.html

相关文章:

  • 网站建设北京市常用的网络推广方式有哪些
  • 放心的网站建设代理搜索引擎营销的案例有哪些
  • 公司网站建设预算东莞优化排名推广
  • 山西响应式网站哪家好电脑网页制作
  • 目前网站建设主流技术架构seo优化中商品权重主要由什么决定
  • 大网站建设公司app网站推广平台
  • 濮阳网站建设0393seo网店运营推广实训
  • it类网站婚恋网站排名前十名
  • 中国互联网协会成立于多少年seo外链
  • 中国建设银行网站能查流水吗四川seo
  • 网站建设推广哪家靠谱网站排名优化查询
  • asp动态网站开发考试十大外贸平台
  • 英文外贸发布网站柳市网站制作
  • 网站诊断表蚌埠seo外包
  • 上海正规做网站公司深圳seo优化电话
  • 招商网站建设服务商seo做什么网站赚钱
  • 金溪那里可以做网站比较好网站制作公司
  • 工信部网站备案查询系统近期10大新闻事件
  • 知名网站制作全包友链提交入口
  • 景区网站建设公司百度认证营销推广师
  • wordpress做登陆页面上海外贸seo公司
  • 程序员必知的网站广告策划方案怎么做
  • 长沙长沙h5网站建设搜索网站
  • 乐山市住房和城乡建设局网站开发一个app需要多少钱
  • wordpress首页文章图片揭阳百度seo公司
  • 成都没有做网站的公司小时seo百度关键词点击器
  • html静态网站开发实验论坛外链代发
  • 中国建设银行河南省分行网站国内比百度好的搜索引擎
  • 科技公司网站推荐搜索引擎排名优化公司
  • 优惠券小程序源码百度seoo优化软件