"id" property of View

The "id" property is an optional textual identifier for the View. With it, you can find the child View.To do this, use the ViewByID function

func ViewByID(rootView View, id string) View

This function looks for a child View with id. The search starts from rootView.If View is not found, the function returns nil and an error message is written to the log.

When searching, you can specify a chain of identifiers. In this case, they must be separated by the '/' character.For example

view := rui.ViewByID(rootView, "id1/id2")

equivalent to

var view rui.View = nil
if view1 := rui.ViewByID(rootView, "id1"); view1 != nil {
	view = rui.ViewByID(view1, "id2")
}

Usually id is set when the View is created and is not changed later.But this is an optional condition. You can change the id at any time.

The Set function is used to set a new value for id. For example

view.Set(rui.ID, "myView")
view.Set("id", "myView")

There are two ways to get the id. The first is using the Get function:

if value := view.Get(rui.ID); value != nil {
	id = value.(string)
}

And the second one is using the ID() function:id = view.ID()