java - DialogFragment with multiple activities -


i used documentation here create dialogfragment. code :

public static myalertdialogfragment newinstance(int title) {     myalertdialogfragment frag = new myalertdialogfragment();     bundle args = new bundle();     args.putint("title", title);     frag.setarguments(args);     return frag; }  @override public dialog oncreatedialog(bundle savedinstancestate) {     int title = getarguments().getint("title");      return new alertdialog.builder(getactivity())             .seticon(r.drawable.alert_dialog_icon)             .settitle(title)             .setpositivebutton(r.string.alert_dialog_ok,                 new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog, int whichbutton) {                         ((fragmentalertdialog)getactivity()).dopositiveclick();                     }                 }             )             .setnegativebutton(r.string.alert_dialog_cancel,                 new dialoginterface.onclicklistener() {                     public void onclick(dialoginterface dialog, int whichbutton) {                         ((fragmentalertdialog)getactivity()).donegativeclick();                     }                 }             )             .create(); }} 

the dialogfragment here associated activity fragmentalertdialog. there way associate multiple activities? have calling activity name in oncreatedialog passing through setarguements(). way use ? checked this question , hoping confirmation/better way.

instead of having fragmentalerdialog activity, define somewhere interface (by somewhere mean either public static interface in dialogfragment class, or separate public interface java file), , activity wishes display dialog implement interface.

one common practice use have root activity project activities. make root activity implement interface , can display dialogfragment anywhere.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

css - Firefox for ubuntu renders wrong colors -