作为解析 XML 文件的结果,我有一个 HashMap 对象的 ArrayList。我想为某个键创建一个值的 ArrayList,以便在 ListView 中显示。这是我到目前为止所拥有的:
// 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() );
}
}
这段代码确实有效,但它是最有效的吗?