0
当我拖动列表并尝试显示所有列表项时,它给了我这样的错误。 这是我在后台工作的AsyncTask。 请给一些错误免费提示.... 这asyncTask在几秒钟内由服务调用。java.lang.IndexOutOfBoundsException:索引8无效,大小为0
@Override
protected ArrayList<HashMap<String, String>> doInBackground(
String... args) {
String url = args[0];
rssItems = rssParser.getRSSFeedItems(url);
FeedDBHandler rssDb = new FeedDBHandler(getApplicationContext());
// RSSItem rssItem;
rssItems.size();
Log.i("size", "size:" + rssItems.size());
for (RSSItem item : rssItems) {
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// Truncating description
String description = item.getDescription();
if (description.length() > 100)
description = description.substring(3, 97) + "..";
// Store in database
rssItem = new RSSItem(item.getTitle(), item.getLink(),
item.getCategory(), description, item.getPubdate());
// check if not exist -notify and insert
if (!rssDb.isExistItem(item.getLink())) {
createNotification(item.getTitle());
rssDb.addFeed(rssItem);
}
createNotification(item.getTitle());
if (map != null) {
map.put(TAG_TITLE, item.getTitle());
map.put(TAG_LINK, item.getLink());
map.put(TAG_CATEGORY, item.getCategory());
map.put(TAG_DESRIPTION, description);
map.put(TAG_PUB_DATE, item.getPubdate());
rssItemList.add(map);
}
}
return rssItemList;
}
@Override
protected void onPostExecute(ArrayList<HashMap<String, String>> rssItemList) {
ListAdapter adapter = new SimpleAdapter(AndroidRSSReaderList.this,
rssItemList, R.layout.rss_item_list_row,
new String[] { TAG_LINK, TAG_TITLE, TAG_DESRIPTION,
TAG_PUB_DATE }, new int[] { R.id.page_url,
R.id.title, R.id.link, R.id.pub_date });
// updating listview
lv.setAdapter(adapter);
lv.deferNotifyDataSetChanged();
// lv.onDataSetChanged();
// dismiss the dialog after getting all products
// pDialog.dismiss();
}
}
在此先感谢...
你有任何想法,为什么这个列表仍然包含您的HTTP呼叫后0元? – bofredo
我没有使用http调用,请给我一些代码提示,所以我可以很清楚地理解.. 谢谢 – AndyBoy
首先,提供发生错误的位置非常有用。将问题缩小为一个体面的块。 – bofredo