¿Cómo iniciar Fragment from Activity?
Tengo un fragmento:
ProductsFragments extends Fragment
y una actividad
AdminMenuActivity extends ActionBarActivity
Quiero llamar a ProductsFragments desde AdminMenuActivity. He usado 2 opciones:
1)
FragmentManager fm = getSupportFragmentManager();
for(int i = 0; i < fm.getBackStackEntryCount(); ++i) {
fm.popBackStack();
}
FragmentTransaction tx = getSupportFragmentManager().beginTransaction();
tx.replace(R.id.frame_layout, android.support.v4.app.Fragment.instantiate(AdminMenuActivity.this, fragments[1]));
tx.commit();
2)
Intent intent1 = new Intent(AdminMenuActivity.this, ProductsActivity.class);
startActivity(intent1);
Ambos han fallado. No quiero extender ProductsFragments con FragmentActivity porque no me da soporte para ActionBar v7
Entonces, ¿cómo llamo?Fragment
?