android - How to define as a view for an AlertDialog a view described in a XML file -
here problem. have alertdialog have title , positive button. want describe content of alertdialog in xml file (except title/button). have created file called dlg_addpwd.xml
in layout resources. here code i'm using:
alertdialog alert = new alertdialog.builder(this); alert.settitle("password access"); alert.setview(findviewbyid(r.layout.dlg_addpwd)); alert.setpositivebutton("add", listenaddpwddlg); alert.show();
i guess line
alert.setview(findviewbyid(r.layout.dlg_addpwd));
is wrong, isn't ? main idea of question is: how define view alertdialog view described in xml file?
thanks
vincent
layoutinflater inflater = (layoutinflater) getsystemservice(context.layout_inflater_service); view layout = inflater.inflate(r.layout.paypaldialog, (viewgroup) findviewbyid(r.id.yourdialog)); alertdialog.builder builder = new alertdialog.builder(yourclass.this) .setview(layout); alertdialog = builder.create(); alertdialog.show();
that how it.
Comments
Post a Comment