java - Sending Data Back to an AlertDialog's Host -


to point: best way send data inputted alertdialog host of alertdialog?

i have alertdialog created dialogfragment created in mainactivity of android application. has ok , cancel buttons, , uses custom layout display edittext box. when user hits ok, contents of edittext box should sent method in host activity of dialog, mainactivity.

i've accomplished creating listener in dialogfragment gets implemented in mainactivity. listener gets invoked , activity receives dialoginterface , string edittext. works fine, seems awfully complicated code-wise seems should able accomplished without code in onclick method of dialog.

is best way pass simple command, such running single method argument in host activity? or changing value of variable of host activity? if wanted use more 1 class of dialogfragment in same activity. have implement listener, , make sure methods in each don't have same names?

thanks.

this pattern fragments , host activity communicate each other. other way plz try "otto event bus". google can find some.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -