How to change view based on value


i have 2 views in my view.c file
i wrote one view in void view1(void) function and other view in void view2(void) function.
i am getting a flag value 0 or 1 from my api. so if flag value is 0 i want to show view1 or if flag value is 1 i want to show view2. how to change view based on flag value.

What MCU/Processor/Board and compiler are you using?


What LVGL version are you using?


What do you want to achieve?

What have you tried so far?

Code to reproduce

Add a code snippet which can run in the simulator. It should contain only the relevant code that compiles without errors when separated from your main code base.

The code block(s) should be formatted like:

/*You code here*/

Screenshot and/or video

If possible, add screenshots and/or videos about the current state.


Is there any update?

I think you’ve answered your own question. Just call the appropriate function based on the flag value you get. You will probably also need some logic to remove the view which is currently displaying.