android - Removing ListView after user selects item -


this 1 should pretty simple. use case have listview generated results of voice search. once user selects appropriate item list, want list disappear. list (its contents) not needed again. know can done in number of ways, not experienced enough know best (quickest, efficient mobile resources...etc.) have used clearchoices(), setvisibility(2) 'gone'. anyway thought go source proper answer.

thanks help. here relevant code, if like:

    protected void onactivityresult(int requestcode, int resultcode, intent data) {     if (requestcode == voice_recognition_request_code && resultcode == result_ok) {          mlist = (listview) findviewbyid(r.id.list);          arraylist<string> matches = data.getstringarraylistextra(recognizerintent.extra_results);         mlist.setadapter(new arrayadapter<string>(this, android.r.layout.simple_list_item_1, matches));          mlist.settextfilterenabled(true);          mlist.setonitemclicklistener(new onitemclicklistener() {             public void onitemclick(adapterview<?> parent, view view, int position, long id) {                 string description = ((textview) view).gettext().tostring();                 final edittext etdesc = (edittext) findviewbyid(r.id.editdescription);                  etdesc.settext(description);                 mlist.setvisibility(2);             }         });     } }    

well, don't know what trying accomplish. can solve creating dialog containing list, , can either dismiss dialog press item, or can "ok" button.

also can separate activity two, , whenever item selected list, finish activity , go previous activity.

another solution, once item selected mlist.setvisibility(view.gone) (or view.invisible depending on want accomplish).

any of these solutions can work, , have decide works best logic of app. hope helps


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -