android - How to dismiss AlertDialog.Builder with custom button -


i have custom alertdialog , want dismiss when user click button.

this code:

    button btn = (button) dialoglayout.findviewbyid(r.id.custom_alert_dialog_horarios_btn_aceptar);      btn.setonclicklistener(new button.onclicklistener() {             @override            public void onclick(view arg0) {             // todo auto-generated method stub             //i want dismiss alertdialog             }});       alertdialog.builder builder = new alertdialog.builder(getactivity());      builder.setview(dialoglayout);     builder.show() 

not answer question fix problem using setpositivebutton , custom settextcolor , setbackgroundcolor.

this new code:

        layoutinflater inflater = getactivity().getlayoutinflater();     view dialoglayout = inflater.inflate(r.layout.custom_alert_dialog_horarios, null);     final textview tv_texto = (textview) dialoglayout.findviewbyid(r.id.custom_alert_dialog_horarios_texto);     final textview tv_titulo = (textview) dialoglayout.findviewbyid(r.id.custom_alert_dialog_horarios_titulo);      //preparamos las fuentes personalizadas     typeface fontalertatitulo = typeface.createfromasset(getactivity().getassets(),"fonts/opensans-semibold.ttf");     typeface fontalertamensaje = typeface.createfromasset(getactivity().getassets(),"fonts/opensans-light.ttf");      tv_titulo.settypeface(fontalertatitulo);     tv_titulo.settext(getresources().getstring(r.string.dias_de_cierre_alert_titulo));      tv_texto.settypeface(fontalertamensaje);     tv_texto.settext(getresources().getstring(r.string.dias_de_cierre_texto));      alertdialog.builder builder = new alertdialog.builder(getactivity());     builder.setpositivebutton(getresources().getstring(r.string.aceptar), null);             builder.setview(dialoglayout);     //builder.show();     alertdialog dialog = builder.create();     dialog.show();   // customize button     button button = dialog.getbutton(dialoginterface.button_positive);     button.settextcolor(getresources().getcolor(color.donostiakirola_texto_general));     button.setbackgroundcolor(getresources().getcolor(color.donostiakirola_fondo_pantalla));       //preparamos las fuentes personalizadas     typeface fonttextoboton = typeface.createfromasset(getactivity().getassets(),"fonts/opensans-semibold.ttf");     button.settypeface(fonttextoboton); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -