How to set an image in an ImageView inside an ExpandableListView group dynamically?

332 views Asked by At

I have a bitmap on Activity and I want to set that bitmap to an ImageView in a group in an ExpandableListView.
How can I do this?

Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));                      (Expandablelistview.imageview).setImageBitmap(bitmap);

I need a particular group of my ExpandableListView and then set that ImageView there.
I need this View reference in the Activity.

1

There are 1 answers

3
Mr.Popular On BEST ANSWER

create array of holders

  ArrayList<ViewHolder> holders = new ArrayList<>();


public class ViewHolder {
    ImageView iv;
}

@Override
public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) {

   ViewHolder holder = new ViewHolder();
    holder.iv = (ImageView)view.findViewById(R.id.imageView);
    holders.add(holder);
    return null;

}

hope you have idea about ViewHolders.. and finally in your activity find the view by the following code and set imageview

holders.get(POSITIONOFLIST).iv.setImageBitmap(bitmap);

hope it helps.