We have already learned about the startup interface. After entering the startup interface, we can open other interfaces, enter the second and third levels, etc.; next we will learn how to open and close other interfaces;

Open the application interface

For example, now we want to open the interface corresponding to sub.ftu. According to the description of the previous analysis of the startup interface, we can know that the interface object corresponding to the UI resource is subActivity, which are automatically generated by the tool for us. Code, we don’t need to pay attention to too many details, just understand it briefly, then we can start the interface with the following code:

EASYUICONTEXT->openActivity("subActivity");

If we want to jump to the sub.ftu interface through a button click, we can call the above statement in the callback interface of the button click event:

static bool onButtonClick_Button1(ZKButton *pButton) {
    // Jump to the sub.ftu interface
    EASYUICONTEXT->openActivity("subActivity");
    return false;
}

Under normal circumstances, the above calling code is sufficient. If some information needs to be passed between the interface and the interface, such as the payment page, we need to use the second parameter of openActivity to pass parameters:

Intent *pIntent = new Intent();
pIntent->putExtra("cmd", "open");
pIntent->putExtra("value", "ok");
EASYUICONTEXT->openActivity("subActivity", pIntent);

In this way, you can receive it in the onUI_intent callback of subLogic.cc:

static void onUI_intent(const Intent *intentPtr) {
    if (intentPtr) {
        // Key value analysis
        std::string cmd = intentPtr->getExtra("cmd");        // "open"
        std::string value = intentPtr->getExtra("value");    // "ok"
        ......
    }
}

Note:

1. The new Intent does not need to be manually deleted, it is automatically deleted within the framework;
2. putExtra only provides the key-value pair method of string. If you need to pass int or other types of values, you need to convert to string type, and then do the corresponding conversion after receiving it in onIntent

Close application interface

Through the open Activity method above, we opened the tabActivity interface. At this time, we want to go back to the original interface, what should we do? We can return to the previous interface through the following code:

EASYUICONTEXT->goBack();

If the return is triggered by a button, we can directly use the tool to set the ID value of the button to sys_back, and the system will also respond to the return function;

If we enter a more hierarchical interface and want to directly go back to our first startup interface, we can achieve it with the following code:

EASYUICONTEXT->goHome();

It returns to the main interface.
In addition, if it is also triggered by a button, we can also use the tool to set the button ID value to sys_home, and the system will respond to the function of returning to the main interface; Finally, we can also close the application interface through the closeActivity method of EasyUIContext, for example, we want to close the subActivity interface:

EASYUICONTEXT->closeActivity("subActivity");

This method requires the caller to know the name of the application to be closed; in addition, this method cannot close the startup interface, which is always present.

powered by Gitbooklast modified: 2021-05-28 12:00:31

results matching ""

    No results matching ""