Search code examples
javaandroidhuawei-mobile-serviceshuawei-developersharmonyos

How to use Fraction (alternative to Fragment) in Harmony OS?


I want to use fragments in my Harmony OS app, and I saw that Fraction is the alternative for it. However, I was unable to find any resource or tutorial as to how to implement it. Can anyone provide an example as to how to use Fraction and FractionAbility to implement Fragments in Harmony OS?


Solution

  • You can refer to this demo.

    This example provides a new layout mode for developers. Fraction is a layout based on the Ability implementation. It can be placed in the Ability container as a part of the container interface and has its own life cycle. Perform operations on Fraction transactions to add, replace, display, hide, and add to the stack.