我已经制作了自定义适配器类
这是代码
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;
}
@Override
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(R.id.rowReceiptTitle);
viewHolder.comments = (TextView) view.findViewById(R.id.rowReceiptComments);
viewHolder.receiptImage = (ImageView) view.findViewById(R.id.rowReceiptImage);
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.setImageBitmap(imageBitmap);
viewHolder.receiptImage.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Intent myIntent = new Intent(v.getContext(), TransferController.class);
myIntent.putExtra("image", blob);
startActivity(myIntent);
}
});
viewHolder.referenceNo.setText(file.getReferenceNo());
viewHolder.comments.setText(file.getComments());
view.setTag(viewHolder);
return view;
}
}
存在问题
myIntent.putExtra("image", blob);
startActivity(myIntent);
startActivity
未得到承认...请告诉我,我想在这里开展一项新活动。我该怎么办......
最好的问候
答案 0 :(得分:19)
尝试这样你可以得到
v.getContext().startActivity(myIntent);
答案 1 :(得分:1)
试试这个:
context.startActivity(myIntent);