0

I have a ListView which contain Button & ImageView, when I click the button it should go to gallery & attach/assign image to ImageView at that position.

But there i am facing a problem , when I click on button,I am calling startActivityForResult from Adapter class & for that onActivityResult is in MainClass(because we can't write it in AdapterClass) where we call adapter. So lets say I know position of ListView then how can we assign image at that position?

Madhu
  • 1,780
  • 23
  • 47
Shreekant N
  • 858
  • 1
  • 13
  • 28
  • http://stackoverflow.com/questions/20015950/can-we-call-startactivityforresult-from-adapterhow-to-get-the-response check this link this may give some clue to get work on – Madhu Sep 01 '15 at 07:35
  • Right way is to modify underlying the data and tell the adapter to refresh – Selvin Sep 01 '15 at 07:38
  • @Madhu hi, calling a function which is in adapter that is fine,but after going their how to modify Image of ImageView of specific position of which we pressed button (we have position number,but how to modify that) – Shreekant N Sep 01 '15 at 10:10
  • @Selvin isnt their any way by which just by knowing position we can change imageView content of that position ? – Shreekant N Sep 01 '15 at 10:13
  • did you try with tabassum Latif answer, that make sense – Madhu Sep 01 '15 at 10:35
  • @Madhu currently looking for adapter.notifydatasetchanged but salvin's ans also working – Shreekant N Sep 01 '15 at 10:45

1 Answers1

1
  1. Make a model
  2. Pass array of model to listAdapter
  3. change the list when you get image from onActivityResult method
  4. then call adapter.notifydatasetchanged()
Tabassum Latif
  • 247
  • 2
  • 15
  • does this adapter.notifydatasetchanged() works if we just edited (like `mItem.get(position).setImage(encodedImage)`)& not used add(),remove(),clear().Because it is giving me NullPointerExeption asking because for ArrayAdapter it is mentioned that it works only for add(),remove() etc – Shreekant N Sep 01 '15 at 10:48