Gestion de rotation de l'écran & Gestion de fragment #20

Open
opened 2 years ago by louis.dufour · 0 comments
Owner

voici les notes que j'avais pris

MainActivity

override fun onCreate(savedInstanceState : Bundle ?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.fenetre_principale)
 
 SupportFragmentManager.fragmentFactory = MaFabriqueFactory(model)

if( resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE)
{

  supportFragmentManager.commit {
         setReorderingAllowed(true)
         add(R.id.accueilMaster,FragmentMaster::Class.java,null)
    }

} else {

  supportFragmentManager.commit {
         setReorderingAllowed(true)
         add(R.id.accueilFragment,FragmentMaster::Class.java,null)
    }
  }
}

MaFabriqueDeFragments

class MaFabriqueDeFragments : FragmentFactory(val model : Promotion) {



override fun instantiiate(classLoader : ClassLoader, className : String) : Fragment =
   
   when(className) {

   fragmentmaster::class.java.name  fragmentMaster(model)
   else  super.instantiate(classloader, className)
}

}
voici les notes que j'avais pris ``MainActivity`` ```Kotlin override fun onCreate(savedInstanceState : Bundle ?) { super.onCreate(savedInstanceState) setContentView(R.layout.fenetre_principale) SupportFragmentManager.fragmentFactory = MaFabriqueFactory(model) if( resources.configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) { supportFragmentManager.commit { setReorderingAllowed(true) add(R.id.accueilMaster,FragmentMaster::Class.java,null) } } else { supportFragmentManager.commit { setReorderingAllowed(true) add(R.id.accueilFragment,FragmentMaster::Class.java,null) } } } ``` ``MaFabriqueDeFragments`` ```Kotlin class MaFabriqueDeFragments : FragmentFactory(val model : Promotion) { override fun instantiiate(classLoader : ClassLoader, className : String) : Fragment = when(className) { fragmentmaster::class.java.name → fragmentMaster(model) else → super.instantiate(classloader, className) } } ```
louis.dufour added the Tâche label 2 years ago
louis.dufour added this to the KanBan project 2 years ago
louis.dufour changed title from Gestion de rotation de l'écran to Gestion de rotation de l'écran & Gestion de fragment 2 years ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

No dependencies set.

Reference: louis.dufour/Android-Projet#20
Loading…
There is no content yet.