dialog - Android SetText in Activity from AlertDialog -
i have textview
on mainactivity
, , create alertdialog
follows:
textviewpropanol = (textview) findviewbyid(r.id.textviewpropranol); boton_propanol = (togglebutton) findviewbyid(r.id.button_propanol); boton_propanol.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(boton_propanol.ischecked()) { textviewpropanol.settext("activacted"); final alertdialog.builder a_builder = new alertdialog.builder(medicamentosactivity.this); a_builder.setcancelable(false) .setitems(r.array.medipropanolol, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { textviewpropanol.settext(); } }) .setnegativebutton("cancel", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { dialog.cancel(); } }) ; alertdialog alert = a_builder.create(); alert.settitle("medicina"); alert.show(); } else{ textviewpropanol.settext("des");} } });
i want set text in textviewpropanol
option selected alertdialog
.
string array[] = new string[]{}; boton_propanol.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if(boton_propanol.ischecked()) { array = getresources().getstringarray(r.array.medipropanolol); textviewpropanol.settext("activacted"); final alertdialog.builder a_builder = new alertdialog.builder(medicamentosactivity.this); a_builder.setcancelable(false) .setitems(r.array.medipropanolol, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { textviewpropanol.settext(array[which]); } }) .setnegativebutton("cancel", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { dialog.cancel(); } }) ; alertdialog alert = a_builder.create(); alert.settitle("medicina"); alert.show(); } else{ textviewpropanol.settext("des");} } });
Comments
Post a Comment