简体   繁体   English

如何在Android Java中使用数组列表创建表数据结构

[英]How to create a table data structure with array lists in Android Java

I am trying to create a table like data structure to hold three array lists associated with each other for an Android application. 我正在尝试创建一个像数据结构这样的表,以容纳三个与Android应用程序相互关联的数组列表。 The first array list will hold index values, the second will hold an actual value and the third will be a flag to say whether the actual value has changed or not. 第一个数组列表将保留索引值,第二个数组列表将保留实际值,第三个数组将是一个标志,用于说明实际值是否已更改。 Would anyone please be able to help me with any advice or tips to solve this problem? 有人能为我提供解决此问题的任何建议或技巧吗? Thank you very much in advance. 提前非常感谢您。

Better use Map by placing a map into a map. 通过将地图放入Map ,更好地使用Map This is a good way to hold 3 data in a row. 这是连续保存3个数据的好方法。

Map <Integer, HashMap<String, Boolean>> table = 
           new HashMap <Integer, HashMap<String, Boolean>>();

The inner Map contains the values: actual value and flag. 内部Map包含值:实际值和标志。 The outer Map contains the index to access the inner map which contains the values. 外部Map包含用于访问包含值的内部Map的索引。

public class A{
 int index, ArrayList<B> list;
}

public class B{
 boolean valueChanged,String actualValue;
}

So in the end use this: 所以最后使用这个:

WeakHashMap<String, List<A>> hashMap;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM