android - AlertDialog doesn't appear, why? -
ok want show alertdialog blank space without message or buttons. know what's going wrong? main class including dialog:
public class mainactivity extends activity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); } public void createdialog1(view view){ final dialogfragment dfragment1=new dialogfragment(); dfragment1.show(getfragmentmanager(), "alarm1"); alertdialog.builder builder = new alertdialog.builder(getapplication()); builder.setmessage(r.string.create_alarm1); builder.setpositivebutton(r.string.yes, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { intent intent1 = new intent(alarmclock.action_set_alarm) .putextra(alarmclock.extra_message, "you have set alarm first hour @ 6:30 am") .putextra(alarmclock.extra_hour, 6) .putextra(alarmclock.extra_minutes, 30); } if (intent1.resolveactivity(getpackagemanager()) != null) { startactivity(intent1); dfragment1.dismiss(); } } }); builder.setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() { @override public void onclick(dialoginterface dialog, int which) { dfragment1.getdialog().cancel(); } });alertdialog dialog1=builder.create(); }
you need show after build, add:
dialog1.show();
Comments
Post a Comment