[英]Android: what is the difference between Bundle Vs java.util collections like HashMap
What is the difference between Bundle Vs java.util collections like HashMap? Bundle Vs java.util collections 和 HashMap 有什么区别?
One difference I can see easily is that a Bundle allows you to put int, boolean, etc., into it while a HashMap seems to require you to convert them to/from objects.我可以轻松看到的一个区别是,Bundle 允许您将 int、boolean 等放入其中,而 HashMap 似乎需要您将它们转换为对象或从对象转换为对象。
A more important difference is that with a Bundle, every object it contains is parcelable.一个更重要的区别是,对于一个 Bundle,它包含的每个 object 都是可包裹的。 This allows Bundles to be used as service parameters and to be attached to intents / passed into activities.
这允许捆绑包用作服务参数并附加到意图/传递到活动中。
A Bundle in Android is a tool the apps use to handle resources. Android 中的 Bundle 是应用程序用来处理资源的工具。 It has built in structure that lets the OS search bundles hierarchically to find a specific resource.
它具有内置结构,可让操作系统分层搜索捆绑包以查找特定资源。
Yes, it is essentially a hash map, but it designed to be a specialized Android component, and not a general purpose data structure.是的,它本质上是一个 hash map,但它被设计为一个专用的 Android 组件,而不是通用数据结构。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.