思路:
跳转到目标fragment所在的activity,并传递一个flag,来确定要到哪个fragment,根据该flag判断后,跳转到指定的fragment即可。
代码:
当前界面:
intent.putExtra("fragment_flag", 3);
目标界面:
fragmentFlag = intent.getIntExtra("fragment_flag", 1);
fManager = getSupportFragmentManager();
FragmentTransaction transaction = fManager.beginTransaction();
switch (fragmentFlag){
case 1:
transaction.replace(R.id.fl_radio_show, mFragments[0]);
navigationBar.check(R.id.tab_monitor_home);
break;
case 2:
transaction.replace(R.id.fl_radio_show, mFragments[1]);
navigationBar.check(R.id.tab_monitor_publish);
break;
case 3:
transaction.replace(R.id.fl_radio_show, mFragments[2]);
navigationBar.check(R.id.tab_monitor_me);
break;
}
transaction.commit();