所以我终于能够自己完成这件事......
我必须编写一个扩展 CursorAdapter 的新方法......
在那里,我必须将我从数据库中获得的所有文本分配给 TextView。因此,我还能够为我的图像加载器提供指向(缓存)图像的链接以加载...
这是我的代码:
private static final class MyCursorAdapter extends CursorAdapter {
MyCursorAdapter(Context context, Cursor cursor, int flags) {
super(context, cursor, flags);
mInflater = LayoutInflater.from(context);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
View v = mInflater.inflate(R.layout.row_twitter, parent, false);
return v;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
TextView listtitle = (TextView) view.findViewById(R.id.listtitle);
TextView listusername = (TextView) view.findViewById(R.id.listusername);
TextView listdate = (TextView) view.findViewById(R.id.listdate);
listtitle.setText(cursor.getString(cursor.getColumnIndex(DataDBAdapter.KEY_TWITTER_TWEET)));
listusername.setText(cursor.getString(cursor.getColumnIndex(DataDBAdapter.KEY_TWITTER_USERNAME)));
listdate.setText(cursor.getString(cursor.getColumnIndex(DataDBAdapter.KEY_TWITTER_DATE)));
listtitle.setTextColor(Color.GRAY);
listdate.setTextColor(Color.GRAY);
ImageView iv = (ImageView) view.findViewById(R.id.image);
imageLoader.displayImage(cursor.getString(cursor.getColumnIndex(DataDBAdapter.KEY_TWITTER_IMAGEURL)),
iv, options);
}
LayoutInflater mInflater;
}
这实际上效果很好:)