0
我工作的新聞Android應用程序,如果我上線我得到RSS通量新聞,我有一個RSSItemAdapter
SQLite數據庫適配器
與此代碼:
class RSSItemAdapter extends ArrayAdapter<RSSItem> {
private final Context context;
final Comment comment = null;
private CommentsDataSource datasource;
public RSSItemAdapter(Context context, int textViewResourceId, List<RSSItem> items) {
super(context, textViewResourceId, items);
this.context = context;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.rssitem, null);
}
final RSSItem item = getItem(position);
TextView tv = (TextView) v.findViewById(R.id.title);
// tv.setText("<a href="+'"'+item.getUrl()+'"'+">"+item.getTitle()+"</a>");
// tv.setText(Html.fromHtml("<a href=\"http://www.google.com\">"+item.getTitle()+"</a>"));
tv.setText(item.getTitle());
//tv.setMovementMethod(LinkMovementMethod.getInstance());
TextView tv1 = (TextView) v.findViewById(R.id.description);
tv1.setText(item.getDescription());
TextView tv2 = (TextView) v.findViewById(R.id.pubdate);
Date date = item.getPubDate();
Format formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz");
String s = formatter.format(date);
tv2.setText(s);
TextView tv3 = (TextView) v.findViewById(R.id.lien);
tv3.setText(item.getUrl());
ImageView iv = (ImageView) v.findViewById(R.id.img);
try {
iv.setImageDrawable(drawable_from_url(item.getImageUrl(), item.getImageTitle()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return v;
}
Drawable drawable_from_url(String url, String src_name) throws java.net.MalformedURLException, java.io.IOException
{
return Drawable.createFromStream(((java.io.InputStream)
new java.net.URL(url).getContent()), src_name);
}
}
後在主類我把它叫做這樣的:
if(isOnline()) {
ListView rssItemList = (ListView) findViewById(R.id.rssListview);
FeedSource feedSource = new HttpFeedSource();
RSSItemAdapter adapter = new RSSItemAdapter(this, R.layout.rssitem, feedSource.getFeed());
rssItemList.setAdapter(adapter);
}
憑什麼我得到的日期存儲在我的SQLite和與這樣的適配器,打印???
我沒有看到在SQLite數據庫是,在這裏。 – njzk2