android - Adding positive / negative Button to DialogFragment's Dialog -


hi i've written dialogfragment. i've realized want have positive , negative button alertdialog. how can achieve such thing while maintaining code i've written?

public class doubleplayerchooser extends dialogfragment { @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);              setstyle(dialogfragment.style_normal,0);    }  @override public dialog oncreatedialog(bundle savedinstancestate) {      return new alertdialog.builder(getactivity())             .settitle("title")             .setpositivebutton("ok",                 new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog, int whichbutton) {                         // something...                     }                 }             )             .setnegativebutton("cancel",                 new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog, int whichbutton) {                         dialog.dismiss();                     }                 }             )             .create(); }    @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {      view v = inflater.inflate(r.layout.doubleplayerchooser, container, false);     getdialog().settitle("enter players");      firstplayerpicker =  (imagebutton) v.findviewbyid(r.id.imagebutton1);     firstplayerpicker.setonclicklistener(new onclicklistener() {         public void onclick(final view v){              callcontactpicker(1);          }            });      secondplayerpicker =  (imagebutton) v.findviewbyid(r.id.imagebutton01);     secondplayerpicker.setonclicklistener(new onclicklistener() {         public void onclick(final view v){              callcontactpicker(2);          }            });      loadfromfile =  (imagebutton) v.findviewbyid(r.id.imagebutton2);     loadfromfile.setonclicklistener(new onclicklistener() {         public void onclick(final view v){            }            });      firsttextfield =  (edittext) v.findviewbyid(r.id.edittext1);     secondtextfield =  (edittext) v.findviewbyid(r.id.edittext01);      firstimage = (imageview) v.findviewbyid(r.id.imageview1);     secondimage = (imageview) v.findviewbyid(r.id.imageview01);        return v; } 

ok how figured out. erased oncreateview , altered oncreatedialog link had answer credit should go there. i've posted in case bumps in thread first

    @override public dialog oncreatedialog(bundle savedinstancestate) {      alertdialog.builder b=  new  alertdialog.builder(getactivity())     .settitle("enter players")     .setpositivebutton("ok",         new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int whichbutton) {                 // something...             }         }     )     .setnegativebutton("cancel",         new dialoginterface.onclicklistener() {             public void onclick(dialoginterface dialog, int whichbutton) {                 dialog.dismiss();             }         }     );      layoutinflater = getactivity().getlayoutinflater();      view v = i.inflate(r.layout.doubleplayerchooser,null);      firstplayerpicker =  (imagebutton) v.findviewbyid(r.id.imagebutton1);     firstplayerpicker.setonclicklistener(new onclicklistener() {         public void onclick(final view v){              callcontactpicker(1);          }            });      secondplayerpicker =  (imagebutton) v.findviewbyid(r.id.imagebutton01);     secondplayerpicker.setonclicklistener(new onclicklistener() {         public void onclick(final view v){              callcontactpicker(2);          }            });      loadfromfile =  (imagebutton) v.findviewbyid(r.id.imagebutton2);     loadfromfile.setonclicklistener(new onclicklistener() {         public void onclick(final view v){            }            });      firsttextfield =  (edittext) v.findviewbyid(r.id.edittext1);     secondtextfield =  (edittext) v.findviewbyid(r.id.edittext01);      firstimage = (imageview) v.findviewbyid(r.id.imageview1);     secondimage = (imageview) v.findviewbyid(r.id.imageview01);       b.setview(v);     return b.create(); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -