android - onActivityResult get position -


i have activity shows listview, listview composed textedit , button. button used pick email of contact , put in textedit.

the listener of button created in custom array adapter , method i'm calling activity pick contact this:

intent intent =new intent(intent.action_pick,contactscontract.commondatakinds.email.content_uri);  ((activity) v.getcontext()).startactivityforresult(intent, mainactivity.act_pick_contact_mail); 

i've created method onactivityresult in activity , can email picked user, don't know wich position button pushed.

this code i've written: know how can ?

 @override protected void onactivityresult(int requestcode, int resultcode, intent data) {         //pick email     if(requestcode==mainactivity.act_pick_contact_mail){         try{             if(resultcode==activity.result_ok){                   uri uri=data.getdata();               cursor emailcur=getcontentresolver().query(uri,null, null, null,null);               emailcur.movetofirst();              string email = emailcur.getstring(emailcur.getcolumnindex(contactscontract.commondatakinds.email.address));               //change first item, need know real position              contactos.set(0, new contacto(email));              adapter.notifydatasetchanged();               emailcur.close();              }}              catch(exception e){              toast.maketext(getbasecontext(), "email wasn't found", toast.length_short).show();                    e.getcause();              }             }   }    

thanks in advance.

edit: solved creating attribute within adaper getter.

i see 2 options here.

one, save position in class attribute of activity. reference when onactivityresult returns.

two, use position request code. eg replace mainactivity.act_pick_contact_mail position. in onactivityresult assume request code of >= 0 valid.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -