i am using a list that is pupolated with a custom adaptor that extends CursorAdaptor, i would like to download images while doing it and place them in the adapter layout, i use intentService to download the image i get it back with a reciver, now i have my image in my onRecive finction but i am buffled as to how i can place it in a view that is in the new CursorAdapter, anybody knows?
the Cursor Adapter:
public class MyAdapter extends CursorAdapter{
public MyAdapter(Context context, Cursor c) {
super(context, c);
// TODO Auto-generated constructor stub
}
@Override
public void bindView(View view, Context context, Cursor c) {
String name = c.getString(c.getColumnIndex(ContractPlaces.Places.NAME));
String address = c.getString(c.getColumnIndex(ContractPlaces.Places.ADDRESS));
String type = c.getString(c.getColumnIndex(ContractPlaces.Places.TYPE));
float rating = c.getFloat(c.getColumnIndex(ContractPlaces.Places.RATING));
String icon = c.getString(c.getColumnIndex(ContractPlaces.Places.ICON));
TextView nameView = (TextView) view.findViewById(R.id.name);
TextView addressView = (TextView) view.findViewById(R.id.address);
TextView typeView = (TextView) view.findViewById(R.id.type);
TextView ratingView = (TextView) view.findViewById(R.id.rating);
ImageView iconView = (ImageView) view.findViewById(R.id.icon);
nameView.setText(name);
addressView.setText(address);
typeView.setText("Type: "+type);
ratingView.setText("Rating: "+String.valueOf(rating));
// iconView - this is where i would like to place tha image from the reciver
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
// TODO Auto-generated method stub
return getActivity().getLayoutInflater().inflate(R.layout.cursor_layout, parent, false);
}
class ImageReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
Bitmap b = intent.getParcelableExtra("image");
//this is the image i would like to place in the view "iconView"
}
Its being a lengthy process to download the image in Intent Service and get that image to adapter class. If you are Interested I have a solution for you.
Use Universal Image Loader library for downloading image. You need not worry about anything. The library itself consists of so many in-built methods. you can use them.
see this
thread for using Universal Image Loader