我必须获取数据列表。
所以我使用了字符串的arraylist和list.here我如何在地图上添加值。
我使用了以下代码:
static final String KEY_TITLE = "Category";
static final String KEY_ARTICLE = "article";
static final String KEY_IMAGE = "image";
final ArrayList<HashMap<String, List<String>>> songsList = new ArrayList<HashMap<String, List<String>>>();
XMLParser parser = new XMLParser();
String xml = parser.getXmlFromUrl(URL); // getting XML from URL
Document doc = parser.getDomElement(xml); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_TITLE);
NodeList nl1 = doc.getElementsByTagName(KEY_ARTICLE);
NodeList nl2 = doc.getElementsByTagName(KEY_IMAGE);
System.out.println(nl.getLength());
for (int i = 0; i < nl.getLength(); i++) {
//System.out.println(nl.getLength());
HashMap<String, List<String>> map = new HashMap<String, List<String>>();
map.put( KEY_TITLE,((Element)nl.item(i)).getAttribute("name"));
for (int j = 0; j < nl1.getLength(); j++) {
map.put( KEY_ARTICLE,((Element)nl1.item(j)).getAttribute("title"));
map.put( KEY_IMAGE,((Element)nl2.item(j)).getAttribute("url"));
}
songsList.add(map);
}
(map.put( KEY_TITLE,((Element)nl.item(i)).getAttribute("name"));)
在这些行上出现以下错误:
The method put(String, List<String>) in the type HashMap<String,List<String>> is not applicable for the arguments (String, String)
我怎样才能清除这些错误..请为我提供解决方案...