これは私の以前の質問に関連しています: Open a DialogFragment from within a CustomView
コールバックを使用して、DialogFragment から値を返す必要があります。このようなことが一般的に行われていることを理解しています:
public class MyDialogFragment extends DialogFragment {
public interface onMultipleSelectionFragmentCloseListener {
public void onMultipleSelectionFragmentOkay();
}
onMultipleSelectionFragmentCloseListener mListener;
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (onMultipleSelectionFragmentCloseListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement onMultipleSelectionFragmentCloseListener");
}
}
....
// to use it
mListener.onMultipleSelectionFragmentOkay();
これは、Activity にコールバックを実装して受信させたい場合です。しかし、カスタム ビューでそれを行う場合はどうすればよいでしょうか (前の質問のように)。