Skip to main content
Version: v4

List Item

CometChatListItem contains one to three lines of text optionally flanked by icons or other widgets, such as CometChatAvatar, CometChatDate or Text. CometChatAvatar will always be shown in the leading view therefore either one among the avatarURL or avatarName must be provided. The icons (or other widgets) for the list item are defined with the tailView parameter. The first line of text is optional and is specified with title. The value of subtitle is also optional, will occupy the space allocated for an additional line of text or some other widget.

Methods

MethodsTypeDescription
setAvatarStringsets image url to be shown in avatar in the leading view
setStatusIndicatorColorColorsets color of the status indicator
setTitleStringsets the title to display
setSubtitleViewWidgetsets custom subtitle below the title
setTailViewWidgetsets the trailing widget, can be a Text, CometChatDate or CometChatBadge
hideSeparatorboolused to hide the divider separating the list items
setStyleListItemStyleused to customize the appearance of this widget
setAvatarStyleAvatarStyleused to customise the Avatar shown in the leading view
setStatusIndicatorStyleStatusIndicatorStyleused to customise the status indicator

ListItemStyle

ListItemStyle is the class containing attributes to customize appearance of this widget.

MethodsTypeDescription
setTitleAppearance@StyleRes

int
used to customise the appearance of the title
setSeparatorColor@ColorInt

int
used to set the color of the divider separating the list items
setBackground@ColorInt

int
used to set the background color
setBackgroundDrawableused to set background gradient
setBorderWidthintused to set border
setCornerRadiusfloatused to set border radius
setBorderColor@ColorInt

int
used to set border color
setSeparatorDrawableDrawableused to set separator color

Usage

<com.cometchat.chatuikit.shared.views.CometChatListItem.CometChatListItem
android:id="@+id/list_item"
android:layout_width="match_parent"
android:background="?attr/selectableItemBackground"
android:clickable="true"
android:focusable="true"
android:layout_height="72dp" />
cometChatListItem = itemView.findViewById(R.id.list_item);
cometChatListItem.setAvatar("url", "Name");
cometChatListItem.setTitle("Name");