android - Not able to get input from the custom fragment dialog -
i displaying custom dialog user input on top of list view activity layout. when seek refer edit text in oncreatedialog() method, coming blank. below code, appreciate if can point out doing wrong -
public class questiondialog extends dialogfragment { public dialog oncreatedialog(bundle savedinstancestate) { alertdialog.builder builder = new alertdialog.builder(getactivity()); // layout inflater layoutinflater inflater = getactivity().getlayoutinflater(); // inflate , set layout dialog final view v =inflater.inflate(r.layout.ques_dialog,null); builder.setview(inflater.inflate(r.layout.ques_dialog, null)) .settitle("title message!") .setcancelable(true) .setpositivebutton("go", new dialoginterface.onclicklistener(){ public void onclick(dialoginterface dialog, int whichbutton) { edittext et1 = (edittext)v.findviewbyid(r.id.et1); // here not able info edit text string s1 = et1.gettext().tostring().trim(); log.d("debug","data -"+s1+" , length"+s1.length()); .... rest code goes here }) .setnegativebutton("cancel", new dialoginterface.onclicklistener(){ public void onclick(dialoginterface dialog, int whichbutton) { ..rest code goes here } }); homecoming builder.create(); } }
that happening because of lines:
final view v =inflater.inflate(r.layout.ques_dialog,null); builder.setview(inflater.inflate(r.layout.ques_dialog, null))
you first inflate v view
, set content of dialog newly inflated view(so in end end looking view isn't actual content of dialog). utilize this:
final view v =inflater.inflate(r.layout.ques_dialog,null); builder.setview(v);
android
No comments:
Post a Comment