dimanche 23 août 2015

Error: Fragment Portrait cannot be converted to Fragment

@Override protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //setContentView(activity_main);

    FragmentManager fragmentManager = getSupportFragmentManager();

    android.support.v4.app.FragmentTransaction fragmentTransaction =
        fragmentManager.beginTransaction();

    Configuration configInfo = getResources().getConfiguration();

    if(configInfo.orientation == Configuration.ORIENTATION_LANDSCAPE){
        FragmentLandscape fragmentLandscape = new FragmentLandscape();
        fragmentTransaction.replace(android.R.id.content,
            fragmentLandscape);
    } else {
        FragmentPortrait fragmentPortrait = new FragmentPortrait();
        fragmentTransaction.replace(android.R.id.content,
            fragmentPortrait);
    }
    fragmentTransaction.addToBackStack(null);
    fragmentTransaction.commit();
}

Aucun commentaire:

Enregistrer un commentaire