java - how to dismiss popupWindow? -


i have popupwindow on activity. however, popupwindow not dismissed after interacting activity.

i want dismiss popup when i'm touching/scrolling/clicking/etc on screen not popupwindow.

public class listviewfordeletecontact extends appcompatactivity {     listview mylistview;     protected  void oncreate(bundle savedinstancestate){         super.oncreate(savedinstancestate);         setcontentview(r.layout.listviewfordeletecontactlayout_main);          mylistview.setonitemclicklistener(new adapterview.onitemclicklistener() {             @override             public void onitemclick(adapterview<?> parent, view view, int position, long id) {                 layoutinflater layoutinflater=(layoutinflater)listviewfordeletecontact.this.getsystemservice(context.layout_inflater_service);                 view dfg= layoutinflater.inflate(r.layout.popupwindowfordeletelayout_main,(viewgroup)findviewbyid(r.id.popupid));                 popupwindow popupwindow=new popupwindow(dfg,420,300,true);                  popupwindow.showatlocation(dfg, gravity.center, 0, 0);                 popupwindow.setoutsidetouchable(true);              }         });     } } 

i tried methods setoutsidetouchable(true); , setbackgrounddrawable(true) did not work me.

 first add  popupwindow.setoutsidetouchable(true); , use  popupwindow.setbackgrounddrawable(new bitmapdrawable(getresources(),             "")); or   popupwindow.setondismisslistener(new popupwindow.ondismisslistener() {      @override     public void ondismiss() {         popupwindow.dismiss();      } }); 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -