简体   繁体   中英

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. 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. This is a good way to hold 3 data in a row.

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

The inner Map contains the values: actual value and flag. The outer Map contains the index to access the inner map which contains the values.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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