android - Populate editText from a listView -
i have edittext, next button. when click button, use onclick trigger intent start new activity, brings listview.
when click item in listview, want listview activity close , populate edittext item. seems i'm going @ wrong, suggestions?
when fire intent, use "startactivityforresult", described in starting activities, getting results.
when fire intent activity listview, line should this:
intent someintent = new intent(someaction, someuri); startactivityforresult(someintent, some_request_code);
within activity listview, before returning, use "setresult" method set proper resultcode (the 1 passed in), , intent holding data.
... intent data = new intent(); data.putextra("key",value); setresult(result_ok, intent data) ....
then, in calling activity, onactivityresult called, containing data.
@override protected void onactivityresult(int requestcode, int resultcode, intent data) { if (requestcode == some_request_code) { //which activity you're returning if (resultcode == result_ok) { // went expected bundle extras = data.getextras(); string val = extras.getstring(key); dosomething(val) ... } } }
hope helps!
Comments
Post a Comment