I'm trying to use an interface to return data from a DialogFragment
to the ArrayAdapter
from which it's shown.
I've read something similar here, but I don't know how to call in the DialogFragment
the function returning the data.
Anybody can help?
MyDialog.java
public class MyDialog extends DialogFragment {
static interface Listener {
void returnData(int result);
}
/* ... */
@Override
public void onActivityCreated (Bundle savedInstanceState){
super.onActivityCreated(savedInstanceState);
mBtnSubmit.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// How can I call PCListAdapter.returnData ?
dismiss();
}
});
}
}
PCListAdapter.java
public class PCListAdapter extends ArrayAdapter<PC> implements MyDialog.Listener {
/* ... */
public void showCommentDialog() {
FragmentManager fm = ((Activity)mContext).getFragmentManager();
MyDialog dialog = new MyDialog();
dialog.show(fm, "mydialog");
}
@Override
public void returnData(int result) {
}
}