GiftPanel (Android Java)

最近更新时间:2025-09-08 22:59:43

我的收藏
礼物选择面板组件 (GiftListPanelView) 展示了后台配置的礼物列表。用户可以点击礼物,将其发送到直播间,并由礼物播放器组件进行播放,从而增强直播互动性。

效果展示


说明:
礼物配置功能需要 TUILiveKit 3.2.0 或以上版本。有关礼物配置后台的详细信息,请参见 礼物配置指引文档

组件接入

参见 准备工作 完成 TUILiveKit 组件接入。

组件使用

礼物面板组件需要直播间信息,因此必须在观众成功进入直播间主播创建直播间后才能使用。

初始化组件

创建 GiftListPanelView 实例并将其添加到您的视图上。您还需要实现 OnSendGiftListener,以便在用户点击发送礼物时获取回调信息。
说明:
此操作必须在进房成功的回调中执行。
Java
GiftListPanelView giftListPanelView = new GiftListPanelView(getContext());

giftListPanelView.init("roomId");
giftListPanelView.setListener(new GiftListPanelView.OnSendGiftListener() {
@Override
public void onSendGift(GiftListPanelView view, Gift gift, int giftCount) {
}
});

giftListPanelView.sendGift(new Gift(), 1, new GiftUser());

自定义礼物面板

如果您需要自定义礼物面板的礼物列表,可以在初始化后通过 setGiftList 方法进行设置。
Java
GiftListPanelView giftListPanelView = new GiftListPanelView(getContext());
giftListPanelView.setGiftList(giftList);