[英]Android hashtable
I want to parse Xml. 我想解析Xml。 In the xml there are multiple items, each item has a description, image and url amongst other things.
在xml中有多个项目,每个项目都有说明,图像和url等。 I want to group all the items with the same description together and then have each item as a menu item.
我想将所有具有相同描述的项目组合在一起,然后将每个项目作为菜单项。 when clicking on the menu item it opens the list of all the items for that description.
单击菜单项时,它将打开该描述的所有项的列表。
Im thinking of using a HashTable
with the key being the description and an ArrayList
. 我正在考虑使用
HashTable
,其键为description和ArrayList
。 Is there any other way? 还有其他办法吗?
Example 例
Something that I cannot figure out is this : 我无法弄清楚的是:
Description URL Image Cars www.ford.com www.ford.com/image.jpg Cars www.vw.com www.vw.com/image.jpg Boat www.suzuki.com www.suzuki.com/image.jpg
So Cars would be the key in the Hashmap
, how do I have 2 String
s? 所以Cars将成为
Hashmap
的关键,我如何有2个String
? and then there would need to be 2 entries for Cars. 然后汽车必须有2个条目。
I support your solution. 我支持您的解决方案。
I am thinking about encapsulate these three attributes as an object, in case that you don't care about the order, i refer using HashTable
with the key of the description and values are ArrayList
with the classes you have created which has the three attributes you described. 我正在考虑将这三个属性封装为一个对象,以防万一您不关心顺序,我使用
HashTable
和描述键进行引用,而值是具有创建的具有三个属性的类的ArrayList
。描述。 With this solution, you can conveniently access all the objects you want. 使用此解决方案,您可以方便地访问所需的所有对象。
Hope to help. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.