I have downloaded an IBM Android tutorial about how to develop an rss with android.
here's the url
http://www.ibm.com/developerworks/xml/tutorials/x-androidrss/
Seems to me it's a little old. I have insert new generics syntax but still have problems to compile at this lines
private void UpdateDisplay()
{
TextView feedtitle = (TextView) findViewById(R.id.feedtitle);
TextView feedpubdate = (TextView) findViewById(R.id.feedpubdate);
ListView itemlist = (ListView) findViewById(R.id.itemlist);
if (feed == null)
{
feedtitle.setText("No RSS Feed Available");
return;
}
feedtitle.setText(feed.getTitle());
feedpubdate.setText(feed.getPubDate());
ArrayAdapter<RssItem> adapter = new ArrayAdapter<RssItem>(this,android.R.layout.simple_list_item_1,feed.getAllItems());
itemlist.setAdapter(adapter);
**itemlist.setOnItemClickListener(this);**
itemlist.setSelection(0);
}
public void onItemClickListener(AdapterView<?> parent, View v, int position, long id)
{
Log.i(tag,"item clicked! [" + feed.getItem(position).getTitle() + "]");
Intent itemintent = new Intent(this,ShowDescription.class);
Bundle b = new Bundle();
b.putString("title", feed.getItem(position).getTitle());
b.putString("description开发者_如何学编程", feed.getItem(position).getDescription());
b.putString("link", feed.getItem(position).getLink());
b.putString("pubdate", feed.getItem(position).getPubDate());
itemintent.putExtra("android.intent.extra.INTENT", b);
//Replacing startSubActivity from the example
startActivityForResult(itemintent,0);
}
The compiler give me error here:
itemlist.setOnItemClickListener(this);
any idea? What's the correct way to do the callback?
Thanks in advance
Cristian is on the right track but you have named your listener method incorrectly.This is wrong...
public void onItemClickListener(AdapterView<?> parent, View v, int position, long id)
It should be...
public void onItemClick(AdapterView<?> parent, View v, int position, long id)
精彩评论