Muhammad Umar Muhammad Umar - 2 years ago 136
Android Question

starting activity on imageview click in custom array adapter

I have made a custom adapter class

here is the code

public class CustomArrayAdapterForReceipts extends ArrayAdapter<Receipt> {
private final Activity context;
public final ArrayList<Receipt> receipt;

public CustomArrayAdapterForReceipts(Activity context, ArrayList<Receipt> receipt) {
super(context, R.layout.row_layout_receipts_listview, receipt);
this.context = context;
this.receipt = receipt;

static class ViewHolder {
protected TextView referenceNo;
protected TextView comments;
protected ImageView receiptImage;

public View getView(int position, View convertView, ViewGroup parent) {

View view = null;
LayoutInflater inflator = context.getLayoutInflater();
view = inflator.inflate(R.layout.row_layout_receipts_listview, null);
final ViewHolder viewHolder = new ViewHolder();

viewHolder.referenceNo = (TextView) view.findViewById(;
viewHolder.comments = (TextView) view.findViewById(;
viewHolder.receiptImage = (ImageView) view.findViewById(;

Receipt file = receipt.get(position);
final byte[] blob = file.getImage();
ByteArrayInputStream inputStream = new ByteArrayInputStream(blob);
Bitmap imageBitmap = BitmapFactory.decodeStream(inputStream);
imageBitmap = Bitmap.createScaledBitmap(imageBitmap, 30, 30, false);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
imageBitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);

viewHolder.receiptImage.setOnClickListener(new View.OnClickListener()
public void onClick(View v)
Intent myIntent = new Intent(v.getContext(), TransferController.class);
myIntent.putExtra("image", blob);



return view;

The problem exists at

myIntent.putExtra("image", blob);

is not being recognized... Please tell me, i want to start a new activity here. What should i do...

BEST Regards

Answer Source

try like this you can get

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download