/** * 跳转到SimpleBackActivity时,只能使用该方法跳转 * * @param cxt 从哪个Activity跳转 * @param code 启动码 * @param page 要显示的Fragment * @param data 传递的Bundle数据 */ public static void postShowForResult( Fragment fragment, int code, SimpleBackPage page, Bundle data) { Intent intent = new Intent(fragment.getActivity(), SimpleBackActivity.class); intent.putExtra(CONTENT_KEY, page.getValue()); intent.putExtra(DATA_KEY, data); fragment.startActivityForResult(intent, code); }
@Override public void setRootView() { setContentView(R.layout.aty_simple_back); int value = getIntent().getIntExtra(CONTENT_KEY, -1); if (value != -1) { try { currentFragment = (TitleBarFragment) SimpleBackPage.getPageByValue(value).newInstance(); changeFragment(currentFragment); } catch (InstantiationException e) { } catch (IllegalAccessException e) { } } }
/** * 跳转到SimpleBackActivity时,只能使用该方法跳转 * * @param cxt * @param page * @param data */ public static void postShowWith(Context cxt, SimpleBackPage page, Bundle data) { Intent intent = new Intent(cxt, SimpleBackActivity.class); intent.putExtra(CONTENT_KEY, page.getValue()); intent.putExtra(DATA_KEY, data); cxt.startActivity(intent); }