在 ForgetPwdConfirmFrag写一个静态方法 newInstance
public static ForgetPwdConfirmFrag newInstance(String phone, String code, String country_source, String country_code) { ForgetPwdConfirmFrag frag = new ForgetPwdConfirmFrag(); Bundle args = new Bundle(); args.putString("phone", phone); args.putString("code", code); args.putString("country_source", country_source); args.putString("country_code", country_code); frag.setArguments(args); return frag; }
跳转的话在Activity中写一个gotoTargetFrag方法
whichFrag是人为好判断哪个fragment,以便点击返回按钮或者图标的时候跳转
public void gotoTargetFrag(BaseAppFrag frag, int whichFrag) { if (frag != null) { getSupportFragmentManager().beginTransaction().replace(R.id.fl_about_login, frag).commitAllowingStateLoss(); this.whichFrag = whichFrag; } }
((AuthorizationLoginActivity) mActivity).gotoTargetFrag(new AuthorizationFrag(), 1);