Revision: 65973
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at February 18, 2014 22:37 by uthopiko
Initial Code
@Override
public void onIconSelect(String fragment) {
Fragment currentFragment = getSupportFragmentManager().findFragmentById(R.id.content_layout);
Fragment newFragment = null;
newFragment = createFragment("fr.vogue.adresses.android." + fragment);
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
if (currentFragment == null) {
transaction.add(R.id.content_layout, newFragment);
} else {
transaction.remove(currentFragment).add(R.id.content_layout, newFragment);
}
transaction.addToBackStack(null);
transaction.commit();
}
private Fragment createFragment(String fragment) {
Fragment newFragment = null;
try {
newFragment = (Fragment) Class.forName(fragment).newInstance();
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return newFragment;
}
Initial URL
Initial Description
2 option for onIconSelect
Initial Title
2 Option for Android Main
Initial Tags
android
Initial Language
Java