java - Why i dont show positiveButton -
i made alertdialog
"positive button" in emulator doesn't show up. what's problem?
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button btndersekle = (button) findviewbyid(r.id.btndersekle); etders = new edittext(mainactivity.this); layoutders = (linearlayout) findviewbyid(r.id.layoutders); alertdialog.builder alertders = new alertdialog.builder(mainactivity.this); alertders.settitle("ders adi giriniz"); alertders.setview(etders); final alertdialog alert = alertders.create(); alertders.setpositivebutton("tamam", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { tvders = new textview(mainactivity.this); tvders.settext(etders.gettext().tostring()); layoutders.addview(tvders); } }); btndersekle.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { alert.show(); } }); } }
you need setpositivebutton
before create alertdialog
. try this:
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button btndersekle = (button) findviewbyid(r.id.btndersekle); etders = new edittext(mainactivity.this); layoutders = (linearlayout) findviewbyid(r.id.layoutders); alertdialog.builder alertders = new alertdialog.builder(mainactivity.this); alertders.settitle("ders adi giriniz"); alertders.setview(etders); alertders.setpositivebutton("tamam", new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { tvders = new textview(mainactivity.this); tvders.settext(etders.gettext().tostring()); layoutders.addview(tvders); } }); final alertdialog alert = alertders.create(); btndersekle.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { alert.show(); } }); } }
Comments
Post a Comment