android - An exception display when I build a PopupWindow? -


i want build popupwindow(there button), when click button, need build popupwindow left of above popupwindow, exception displays (android.view.windowmanager$badtokenexception: unable add window -- token android... activity running?). how can do?

class myactivity extends activity{      popupwindow selectpop;     textview _tv_reset,_tv_confirm;     listview lv;     private hashmap<string,string> data;     private searchproductselectadapter adapt;      public void initselectpop(){         //here layout of first popupwindow         view v = layoutinflater.from(context).inflate(r.layout.search_product_select_pop_layout,null);         //here listview in view v         lv = (listview) v.findviewbyid(r.id.search_product_select_lv);         //here itemclicklistener of lv         lv.setonitemclicklistener(new onitemclicklistener() {              @override             public void onitemclick(adapterview<?> parent, view view, int position, long id) {                 initparamsetpop(position);             }         });         //here set adapter lv         lv.setadapter(adapt);         //here build instance of popupwindow         selectpop = new popupwindow(v,getresources().getdisplaymetrics().widthpixels *  1/3,layoutparams.match_parent);         //here display first popupwindow         selectpop.showasdropdown(_tv_shaixuan, 0, 0);     }     popupwindow paramsetpop;     edittext _et_start_price,_et_end_price;     listview _lv;     textview confirm;     //here init second popupwindow     public void initparamsetpop(int position){             //here second layout of popupwindow             view v = layoutinflater.from(context).inflate(r.layout.price_param_set_layout, null);         //here build instance of second popupwindow         paramsetpop = new popupwindow(v,getresources().getdisplaymetrics().widthpixels * 1/4,layoutparams.match_parent);         //here display second popupwindow         paramsetpop.showasdropdown(_tv_reset);       } } 

the problem context. instead getapplicationcontext() use youractivity.this


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -