Hongmeng Development-the first development of Hongmeng system application

Maybe I was trapped by the information cocoon of the headlines, and news of Hongmeng always appeared. I did not develop the mobile app, but out of curiosity, I tried to develop it.

First, I went to Hongmeng official website   https://hmxt.org/ to   download the IDE, then installed it, and generated a Hello Word project following the IDE's documentation.

This is the document

https://developer.harmonyos.com/cn/docs/documentation/doc-guides/hello_world-0000001054516888

Then write the first XML page according to the introductory document

First, create two folders layout, graphic and two xml   main_layout.xml and button_element.xml in the project directory

main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
        xmlns:ohos="http://schemas.huawei.com/res/ohos"
        ohos:width="match_parent"
        ohos:height="match_parent"
        ohos:background_element="#000000">

    <Text
            ohos:id="$+id:text"
            ohos:width="match_content"
            ohos:height="match_content"
            ohos:center_in_parent="true"
            ohos:text="Hello World"
            ohos:text_color="white"
            ohos:text_size="32fp"/>

    <Button
            ohos:id="$+id:button"
            ohos:width="match_content"
            ohos:height="match_content"
            ohos:text_size="19fp"
            ohos:text="Next"
            ohos:top_padding="8vp"
            ohos:bottom_padding="8vp"
            ohos:right_padding="80vp"
            ohos:left_padding="80vp"
            ohos:text_color="white"
            ohos:background_element="$graphic:button_element"
            ohos:center_in_parent="true"
            ohos:align_parent_bottom="true"/>
</DependentLayout>
button_element.xml
<?xml version="1.0" encoding="utf-8"?>
<shape
        xmlns:ohos="http://schemas.huawei.com/res/ohos"
        ohos:shape="oval">
    <solid
            ohos:color="#007DFF"/>
</shape>

Then modify the MainAbilitySlice.java file according to the document

Comment out the onStart method   super.onStart(intent); the following code, and then add super.setUIContent(ResourceTable.Layout_main_layout);

But the strange thing is that there is no Layout_main_layout constant in ResourceTable at all, and then I flipped through this class, and there was no such thing. Even more strange is that this class is not in the src directory, here

Then the program didn't work well. The tutorial didn't say how to deal with it. I just found a Changliang and put it in setUIContent and ran it once. The simulator on the right flashed back to the original appearance. At this time, a magical thing happened. When I opened this class again, there were many more constants. . . . . .

The previous code is like this

 

public final class ResourceTable {
    public static final int Media_icon = 0x1000002;

    public static final int String_app_name = 0x1000000;
    public static final int String_mainability_description = 0x1000001;
}

Later, a few more constants

public final class ResourceTable {
    public static final int Graphic_button_element = 0x1000003;

    public static final int Id_button = 0x1000005;
    public static final int Id_text = 0x1000006;

    public static final int Layout_main_layout = 0x1000004;

    public static final int Media_icon = 0x1000002;

    public static final int String_app_name = 0x1000000;
    public static final int String_mainability_description = 0x1000001;
}

I don’t know how the operation of this step is done, and the error code is generated after running it once. There is no introduction in the formal operation document...

There is no Hongmeng in the article tag, so I chose an Android blindly.

Guess you like

Origin blog.csdn.net/T262702247/article/details/108550941