java - Dialog doesn't show android -


i'm trying on listener launch modal, , have 2 weird runs.

1) error without explanation.

2) nothing, no error, modal doesn't appear.

here code :

private void onjoined(jsonobject camp){     looper.prepare();      final dialog dialog = new dialog(this);     dialog.requestwindowfeature(window.feature_no_title);     dialog.getwindow().setbackgrounddrawable(new colordrawable(android.graphics.color.transparent));     windowmanager.layoutparams lp = new windowmanager.layoutparams();     window window = dialog.getwindow();     lp.copyfrom(window.getattributes());     //this makes dialog take full width     lp.width = windowmanager.layoutparams.match_parent;     window.setattributes(lp);     dialog.setcontentview(r.layout.modal_layout);      button dialogbutton = (button) dialog.findviewbyid(r.id.modal_btn1);     // if button clicked, close custom dialog     dialogbutton.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             dialog.dismiss();         }     });     dialog.show(); } 

can on ?

why calling looper.prepare ?

try if you're not on main thread :

private void onjoined(jsonobject camp){     this.runonuithread(new runnable() {         public void run() {             final dialog dialog = new dialog(this);             dialog.requestwindowfeature(window.feature_no_title);             dialog.getwindow().setbackgrounddrawable(new colordrawable(android.graphics.color.transparent));             windowmanager.layoutparams lp = new windowmanager.layoutparams();             window window = dialog.getwindow();             lp.copyfrom(window.getattributes());             //this makes dialog take full width             lp.width = windowmanager.layoutparams.match_parent;             window.setattributes(lp);             dialog.setcontentview(r.layout.modal_layout);              button dialogbutton = (button) dialog.findviewbyid(r.id.modal_btn1);             // if button clicked, close custom dialog             dialogbutton.setonclicklistener(new view.onclicklistener() {                 @override                 public void onclick(view v) {                     dialog.dismiss();                 }             });             dialog.show();         }     }); } 

Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -