I have an ArrayList of HashMap objects as result of parsing an XML file. I would like to create an ArrayList of values for a certain key for display in a ListView. Here is what I have so far:
// Initialize the guideList ArrayList
ArrayList<String> guideList = new ArrayList<String>();
HashMap<String,Object> dict = null;
// Get the data - returns an ArrayList
Object obj = plist.getConfigurationObject("array");
// make sure an ArrayList was returned
if (obj instanceof ArrayList) {
// initialize Iterator
Iterator itr = ((ArrayList) obj).iterator();
int i = 0;
// Loop through and create guideList ArrayList
while (itr.hasNext()) {
itr.next();
dict = ((ArrayList<HashMap>) obj).get(i++);
Object guideNo = dict.get("GUIDE_NO");
guideList.add( "Guide "+guideNo.toString() );
}
}
This code does work, but is it the most efficient?