UIKit Android v3
UIKit Android
UIKit
Android
Version 3
Home
/
UIKit
/
Android
/
Customization

Bind event handlers to the view

Copy link

In all UIKit fragments, you can override the onBeforeReady() method. In order to receive events that occur in the view of a component, a binding method is called. Each component has a binding method, such as onBindMessageInputComponent, which is called to bind event handlers to the fragment. If you inherited the fragment, we recommend that you set the event handlers of the component within the onBeforeReady() method or the binding method.

Note: In the code below, the tap event of the left button in MessageInputComponent is used as an example but you can replace it with any other events.

public class CustomChannelFragment extends ChannelFragment {

    // TODO : Override `onBeforeReady()` or `onBindMessageInputComponent`.

    @Override
    protected void onBindMessageInputComponent(@NonNull MessageInputComponent inputComponent, @NonNull ChannelViewModel viewModel, @Nullable GroupChannel channel) {
        super.onBindMessageInputComponent(inputComponent, viewModel, channel);
        // TODO : Customize the event handler using a setter method of the `MessageInputComponent`.
        inputComponent.setOnInputLeftButtonClickListener(v -> showMediaSelectDialog());
    }
}

Note: We recommend you to bind the event handlers of a component after the onCreateView() of the module is called.