How can I add clickHandler to the <li> tag in GWT?

I want to add ClickHandler in the <li> tag

Please help me...

+3
source share
3 answers

You can use FocusWidget after you have mastered the Element. There, the FocusWidget constructor accepts one element. After that, you can simply call addClickHandler

+2
source

You need to have a tag <li>as a widget that implements the HasClickHandler interface. Then you can create an instance of ClickHandler and add it to the widget <li>.

+2
source

, . , , .

public class ListItem extends HTMLPanel implements HasClickHandlers {
    public ListItem(String html) {
        super(html);
    }

    @Override
    protected void setElement(Element elem) {
        super.setElement(DOM.createElement("li"));
    }

    @Override
    public HandlerRegistration addClickHandler(ClickHandler handler) {
        return addDomHandler(handler, ClickEvent.getType());
    }
}

UiBinder ListItem, HTML ( ).

0

Source: https://habr.com/ru/post/1728032/


All Articles