android - onActivityResult in RecyclerView.Adapter<MyAdapter.MyViewHolder> -


i tried open gallery adapter.

emp_photo_edit.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 intent = new intent(intent.action_pick,android.provider.mediastore.images.media.external_content_uri);                 ((employeeactivity)context).startactivityforresult(i, 2017);             }         }); 

then want show choosen image imageview in recycycleview, how that? because cant add onactivityresulton adapter. in advance

edit

my full code

public static class myviewholder extends recyclerview.viewholder {     ....      public myviewholder(view v) {         super(v);         ....      }     public void bind(final employee item, final onitemclicklistener listener, final context context) {         ....         generatedialog(item,dialog_employee);         ....      }      ...     ...     void generatedialog(employee item, view v){         //dialog child         //photo         emp_photo_edit.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view v) {                 intent = new intent(intent.action_pick,android.provider.mediastore.images.media.external_content_uri);                 ((employeeactivity)context).startactivityforresult(i, 2017);             }         });         ....     } } 

your result arrive in employeeactivity in onactivityresult. since picking image, result uri have retrieve first, bind appropriate item. suggest following sequence of actions:

  1. create new request code stores item position , identifies request. if there no other requests, can make row id request code.
  2. get uri using data.getdata() , remember received request code. make sure result code activity.result_ok.
  3. feed uri , request code (which contains item id) loader or similar retrieve image.
  4. store resulting image somewhere accessible myviewholder item id. example, can create map inside store loaded images.
  5. find position item id in adapter , call notifyitemchanged on adapter position received. can call either notifyitemchanged(int position) full rebind, or notifyitemchanged(int position, object payload) payload bitmap.

Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - IE9 error '$'is not defined -