-1

我创建了一个 RSS 阅读器,并成功地解析了 XML 文件中的数据。我已经提取了标题,我希望显示这些标题。我将标题存储到一个字符串数组中,我希望以合适的方式显示所有标题(我有 70 个标题)。我正在考虑使用 Listview 。还有其他更简单的方法吗?

4

2 回答 2

0

ListView is exactly designed for this. I would create a custom ArrayAdapter to be the adapter for your ListView. You just need to override the add(), getCount(), and getView() methods to have something up and running. Then you can store your list of XML data directly within the adapter and easily add to it.

This is a pretty good tutorial: http://www.ezzylearning.com/tutorial.aspx?tid=1763429

Only change I would make is to make data[] a List instead and add the add() and getCount() methods.

于 2012-08-03T15:50:42.320 回答
0

ArrayAdapter正如 Atlos 所暗示的那样,Custom是恕我直言,是一种矫枉过正。ArrayAdapter<String>在字符串数组上使用股票。对于item模板ID,Android中有现成的模板;我会推荐android.R.layout.simple_list_item_1

于 2012-08-03T15:54:01.887 回答