Dynamically managing fragments

The process of dynamically managing fragments commonly involves multiple steps. The steps may be simple like removing one fragment and adding another, or they may be more complex, involving the removal and addition of multiple fragments. In any case, we need to be certain that all dynamic changes to the fragments within an activity that constitute a shift from one application screen to the next occur together as a single unit of work. Android does this by grouping the steps into transactions using the FragmentTransaction class.

Conceptually, the FragmentTransaction class behaves in a manner consistent with other transaction models: start the transaction, identify the desired changes, and commit the transaction once ...

Get Creating Dynamic UI with Android Fragments now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.