I have an recycler view adapter class and in bind view holder i want to get image from gallery and set it to image view. In bindview there are issues coming in this for over riding this basically i want to open gallery and select image and set it on imageview.
@Override
public void onBindViewHolder(@NonNull ViewHolder holder, final int position) {
Cheque_Payment chqadd_list = cheques_list.get(position);
ImageView imageView=holder.imageView;
holder.imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setType("images/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
contxt.startActivity(intent);
startActivityForResult(intent,IMG_REQUEST);
}
});
holder.Chq_Amount.setText(cheques_list.get(position).getChequeAmount());
holder.Chq_No.setText(cheques_list.get(position).getChequeNumber());
holder.Chq_Date.setText(cheques_list.get(position).getChequeDate());
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IMG_REQUEST && resultCode == RESULT_OK && data != null) {
Uri path = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), path);
imageview.setImageBitmap(bitmap);
imageview.setVisibility(View.VISIBLE);
// chx.setChequeImage(imageview.);
} catch (IOException e) {
e.printStackTrace();
}
}
}