-1

I am basically trying to set an image to an ImageView which is an item in a ListView. The listview contains items that has ImageViews in them. I am trying to change the Imageview of the first item in that list.

crop_doneBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Bitmap croppedImage = CropImageView.getCroppedImage();

                //Instance of the adapter
                ProfileAdapter adapter =
                        new ProfileAdapter(EyewerProfile.this,
                                listData) {

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

                                View view = super.getView(position, convertView, parent);
                                //The ImageView I need
                                ImageView userpic = (ImageView) view.findViewById(R.id.userpic);

                                userpic.setImageBitmap(croppedImage);

                                return view;
                            }
                        };
            }
        });

This doesn't do anything and the imageview of the item doesn't change and it doesn't crash either. Am I doing it right?

Jay
  • 4,873
  • 7
  • 72
  • 137

1 Answers1

0

Try something like

ImageView userpic = (ImageView) yourListView.getItemAtPosition(position);
userpic.setImageBitmap(croppedImage);

position should be 0 in your case.

A Nice Guy
  • 2,676
  • 4
  • 30
  • 54