@Override public void onDismiss(DialogInterface dialog) { super.onDismiss(dialog); if(mListener != null && limitValue !=null) { mListener.onDialogDismiss(limitValue); } } /** * 回调接口入口 */ public void setListener(OnFragmentInteractionListener listener) { this.mListener = listener; } /** * 接口 */ public interface OnFragmentInteractionListener { void onDialogDismiss(LimitValue limitValue); } /** * 私有化实例 */ private OnFragmentInteractionListener mListener;
调用的地方创建对象设置监听,执行相关操作
KvalueDialogFragment dialog2 = new KvalueDialogFragment(); dialog2.setListener(new KvalueDialogFragment.OnFragmentInteractionListener() { @Override public void onDialogDismiss(LimitValue limitValue) { mTextK.setText(limitValue.getK()); } });