Android Creating a Custom AlertDialog in DialogFragment -


i trying create alertdialog contains next , close button , checkbox "don't show again". use support library dialogfragment. following code works fine want use own xml layout alertdialog:

    @override     public dialog oncreatedialog(bundle savedinstancestate) {         int title = getarguments().getint("num");          alertdialog.builder builder = new alertdialog.builder(getactivity());                  builder.settitle("asdasdas")                 .setpositivebutton(r.string.hello_world,                     new dialoginterface.onclicklistener() {                         public void onclick(dialoginterface dialog, int whichbutton) {                             ((mainactivity)getactivity()).dopositiveclick();                         }                     }                 )                 .setnegativebutton(r.string.cancel,                     new dialoginterface.onclicklistener() {                         public void onclick(dialoginterface dialog, int whichbutton) {                             ((mainactivity)getactivity()).donegativeclick();                         }                     }                 );                 return builder.create();     } 

is possible use own xml layout create alertdialog?

this how create completly custom alertdialog in dialogfragment using own xml layout.

@override public dialog oncreatedialog(bundle savedinstancestate) {     alertdialog.builder builder = new alertdialog.builder(getactivity());     // layout inflater     layoutinflater inflater = getactivity().getlayoutinflater();      // inflate , set layout dialog     // pass null parent view because going in dialog layout     builder.setview(inflater.inflate(r.layout.dialog_signin, null))     // add action buttons            .setpositivebutton(r.string.signin, new dialoginterface.onclicklistener() {                @override                public void onclick(dialoginterface dialog, int id) {                    // sign in user ...                }            })            .setnegativebutton(r.string.cancel, new dialoginterface.onclicklistener() {                public void onclick(dialoginterface dialog, int id) {                    logindialogfragment.this.getdialog().cancel();                }            });           return builder.create(); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -