我正在使用擴展CursorAdaptor的自定義適配器pupolated的列表,我想下載圖像,並將它們放在適配器佈局中,我使用intentService來下載圖像我拿回了一個reciver,現在我在我的onRecive finction中有我的圖像,但是我爲什麼可以將它放在新的CursorAdapter中的視圖中,有人知道嗎?我怎樣才能通過意圖傳遞視圖android
光標適配器:
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"
}
我認爲你不會說像char,float和其他許多數據類型。你也忘記了可序列化的對象。 –
@Shayanpourvatan,是的,但我的意思是原始數據類型,但我會添加它謝謝 –