I've implemented a CardScrollAdapter
to show a list of Cards
in Google Glass. Each card has text and an image. I want the image to come from a content provider (specifically, MediaStore.Video.Thumbnails
) so it must be loaded in an AsyncTask
.
How can I modify the view returned from the adapter's getView
method from the AsyncTask
, where the view is obtained from a Card
?
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if(convertView == null) {
view = mInflater.inflate(R.layout.movie_row, parent, false);
} else {
view = convertView;
}
mVideoColumnIndex = mCursor.getColumnIndexOrThrow(MediaStore.Video.Media.DISPLAY_NAME);
mIdColumnIndex = mCursor.getColumnIndexOrThrow(MediaStore.Video.Media._ID);
mCursor.moveToPosition(position);
Card card = new Card(mContext);
card.setImageLayout(ImageLayout.FULL);
card.setText(mCursor.getString(mVideoColumnIndex));
card.setFootnote((String.format("%d of %d", mCursor.getPosition() + 1, mCursor.getCount())));
long id = mCursor.getLong(mIdColumnIndex);
// AsyncTask not included for brevity (since it doesn't work yet)
new ImageLoader().execute(card, Long.valueOf(id));
return card.getView();
}
You need to create your owns layouts. If you use Card
, you can't modify the image after calling getView()
If you don't know how to do a similar layout of Card
, Google give you some examples here: https://developers.google.com/glass/develop/gdk/ui-widgets#xml_layouts
PD: I think that you could change the image if you could know the id of the imageView that is created when card.getView()
is called and i think you can do this while you are debuging and cheking the variables.