【发布时间】:2016-09-15 10:34:54
【问题描述】:
我正在尝试开发一个 rss 阅读器 首先,我准备了一个 arraylist 变量菜单项 2000 包含(标题,链接,描述)以将其显示在列表项中 但是列表视图将三个字符串一起显示在一行中,如图所示: Here
这里是来源:
ArrayList<HashMap<String, String>> menuItems2000 = new ArrayList<HashMap<String, String>>();
TextView textview10 = (TextView) findViewById(R.id.textview10);
TextView textview11 = (TextView) findViewById(R.id.textview11);
TextView textview12 = (TextView) findViewById(R.id.textview12);
ListView listview10 = (ListView) findViewById(R.id.listview10);
//----------------------------------------------
Document doc = getDomElement(contentAsString2); // getting DOM element
NodeList nl = doc.getElementsByTagName(KEY_ITEM);
// looping through all item nodes <item>
for (int i = 0; i < nl.getLength(); i++) {
//creating new HashMap
HashMap<String, String> map2000 = new HashMap<String, String>();
Element e = (Element) nl.item(i);
// adding each child node to HashMap key => value
map2000.put(KEY_TITLE, getValue(e, KEY_TITLE));
map2000.put(KEY_LINK, getValue(e, KEY_LINK));
map2000.put(KEY_DESC, getValue(e, KEY_DESC));
// adding HashList to ArrayList
menuItems2000.add(map2000);
}
//---add menuItems to liat view------------------
textview10.setText("finish");
ListAdapter adapter = new SimpleAdapter(
listviewrss.this,
menuItems2000,
R.layout.listviewrss,
new String[]{KEY_TITLE,KEY_LINK,KEY_DESC},
new int[]{R.id.textview10, R.id.textview11,
R.id.textview12 } );
listview10.setAdapter(adapter);
【问题讨论】:
标签: android listview arraylist