tencent cloud

文档反馈

会话列表

最后更新时间:2024-10-30 10:59:38
    下文将向您展示如何设置会话列表界面自定义选项及其效果。

    设置会话列表、cell 背景色

    API 作用:设置会话列表、cell、置顶 cell 的背景色。
    API 原型:
    // TUIConversationConfigMinimalist.java
    /**
    * Background color of conversation list.
    */
    public static void setListBackground(Drawable listBackground)
    /**
    * Background color of cell in conversation list.
    * This configuration takes effect in all cells.
    */
    public static void setCellBackground(Drawable cellBackground)
    /**
    * Background color of pinned cell in conversation list.
    * This configuration takes effect in all pinned cells.
    */
    public static void setPinnedCellBackground(Drawable pinnedCellBackground)
    示例代码:
    // When to call: Before initializing conversation list.
    TUIConversationConfigMinimalist.setListBackground(new ColorDrawable(Color.BLUE));
    TUIConversationConfigMinimalist.setCellBackground(new ColorDrawable(Color.LTGRAY));
    TUIConversationConfigMinimalist.setPinnedCellBackground(new ColorDrawable(Color.GRAY));
    设置效果:
    设置背景色
    默认
    
    
    
    
    
    

    设置会话列表 cell 字体

    API 作用:设置会话列表 cell 上的标题、副标题、时间文字的字体。针对所有 cell 生效。
    API 原型:
    // TUIConversationConfigMinimalist.java
    /**
    * Font of title label of cell in conversation list.
    * This configuration takes effect in all cells.
    */
    public static void setCellTitleLabelFontSize(int cellTitleLabelFontSize)
    /**
    * Font of subtitle label of cell in conversation list.
    * This configuration takes effect in all cells.
    */
    public static void setCellSubtitleLabelFontSize(int cellSubtitleLabelFontSize)
    /**
    * Font of time label of cell in conversation list.
    * This configuration takes effect in all cells.
    */
    public static void setCellTimeLabelFontSize(int cellTimeLabelFontSize)
    示例代码:
    // When to call: Before initializing conversation list.
    TUIConversationConfigMinimalist.setCellTitleLabelFontSize(18);
    TUIConversationConfigMinimalist.setCellSubtitleLabelFontSize(14);
    TUIConversationConfigMinimalist.setCellTimeLabelFontSize(16);
    设置效果:
    设置字体
    默认
    
    
    
    
    
    

    展示未读红点

    API 作用:展示 cell 上的未读消息红点 icon。针对所有 cell 生效。
    API 原型:
    // TUIConversationConfigMinimalist.java
    /**
    * Display unread count icon in each conversation cell.
    * The default value is true.
    */
    public static void setShowCellUnreadCount(boolean showCellUnreadCount)
    示例代码:
    // When to call: Before initializing conversation list.
    TUIConversationConfigMinimalist.setShowCellUnreadCount(false);
    设置效果:
    不展示会话 cell 上的未读红点
    默认
    
    
    
    
    
    

    展示在线状态

    API 作用:展示 cell 里用户头像上的在线状态 icon。针对所有 cell 生效。
    API 原型:
    // TUIConversationConfigMinimalist.java
    /**
    * Display user's online status icon in conversation list.
    * The default value is false.
    */
    public static void setShowUserOnlineStatusIcon(boolean showUserOnlineStatusIcon)
    示例代码:
    // When to call: Before initializing conversation list.
    TUIConversationConfigMinimalist.setShowUserOnlineStatusIcon(true);
    设置效果:
    展示在线状态
    默认
    
    
    
    
    
    

    会话更多菜单选项自定义

    API 作用:隐藏会话更多菜单选项、向会话更多菜单添加选项。针对指定会话生效。
    API 原型:
    // TUIConversationConfigMinimalist.java
    public interface ConversationMenuItemDataSource {
    /**
    * Implement this method to add new items.
    */
    default List<ConversationPopMenuItem> conversationShouldAddNewItemsToMoreMenu(ConversationInfo conversationInfo) { return new ArrayList<>(); }
    /**
    * Implement this method to hide items in more menu.
    */
    default @ConversationMenuItem List<Integer> conversationShouldHideItemsInMoreMenu(ConversationInfo conversationInfo) { return new ArrayList<>(); }
    }
    示例代码:
    // When to call: Before initializing conversation list.
    TUIConversationConfigMinimalist.setConversationMenuItemDataSource(new TUIConversationConfigMinimalist.ConversationMenuItemDataSource() {
    @Override
    public List<Integer> conversationShouldHideItemsInMoreMenu(ConversationInfo conversationInfo) {
    return Arrays.asList(TUIConversationConfigMinimalist.HIDE,
    TUIConversationConfigMinimalist.PIN);
    }
    @Override
    public List<ConversationPopMenuItem> conversationShouldAddNewItemsToMoreMenu(ConversationInfo conversationInfo) {
    ConversationPopMenuItem item = new ConversationPopMenuItem();
    item.text = "action1";
    item.iconResId = R.drawable.ic_launcher;
    item.onClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    ToastUtil.toastShortMessage("action1 clicked");
    }
    };
    ConversationPopMenuItem item2 = new ConversationPopMenuItem();
    item2.text = "action2";
    item2.iconResId = R.drawable.ic_launcher;
    item2.onClickListener = new View.OnClickListener() {
    @Override
    public void onClick(View v) {
    ToastUtil.toastShortMessage("action2 clicked");
    }
    };
    return Arrays.asList(item, item2);
    }
    });
    设置效果:
    隐藏、添加选项
    默认
    
    
    

    
    
    

    
    联系我们

    联系我们,为您的业务提供专属服务。

    技术支持

    如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

    7x24 电话支持