Skip to content

Instantly share code, notes, and snippets.

@emcenrue emcenrue/stuff.java
Created Apr 26, 2017

Embed
What would you like to do?
@Override
public void changeFragment(String fragment_name) {
Fragment fragment;
Class fragmentClass = null;
if(fragment_name.equals(TeamFragment.TAG_TEAM_FRAGMENT)){
fragmentClass = TeamFragment.class;
Log.d("HW2", "team fragment selected");
}
else if(fragment_name.equals(MyStepsFragment.TAG_MY_STEPS_FRAGMENT)){
fragmentClass = MyStepsFragment.class;
Log.d("HW2", "team fragment selected");
}
else if(fragment_name.equals(TeamsRankFragment.TAG_TEAM_RANK_FRAGMENT)){
fragmentClass = TeamsRankFragment.class;
Log.d("HW2", "team rank fragment selected");
}
try {
if (fragmentClass != null) {
fragment = (Fragment) fragmentClass.newInstance();
FragmentTransaction ft= fragmentManager.beginTransaction();
Log.d("hello", fragment_name); //dashboard_fragment
Log.d("hello2", ((RetainedFragmentInteraction)taskFragment).getActiveFragmentTag()); //home_fragment
ft.replace(R.id.frame, fragment,
((RetainedFragmentInteraction)taskFragment).getActiveFragmentTag());
ft.addToBackStack(null);
ft.commit();
}
} catch (Exception e) {
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.