/ UIKit / Android View
UIKit
Chat UIKit Android View v3
Chat UIKit Android View
Chat UIKit
Android View
Version 3

Customize list adapters

Copy link

Sendbird UIKit for Android's list adapters are structured similarly to the basic implementation of Android's RecyclerView. All adapters using UIKit's RecyclerView can be customized.

When to customize

Copy link

The following are some example cases of when to consider customization:

  • To modify existing items in the RecyclerView.
  • To introduce a new type of item.

UIKit's list adapters of RecyclerView

Copy link

The following table shows a list of all fragments and its corresponding adapters.

FragmentAdapter

ChannelListFragment

ChannelListAdapter

ChannelFragment

MessageListAdapter

OpenChannelFragment

OpenChannelMessageListAdapter

CreateChannelFragment

CreateChannelUserListAdapter

InviteUserFragment

InviteUserListAdapter

RegisterOperatorFragment

RegisterOperatorListAdapter

OpenChannelRegisterOperatorFragment

OpenChannelRegisterOperatorListAdapter

MemberListFragment

MemberListAdapter

ParticipantsListFragment

ParticipantListAdapter

BannedUserListFragment

BannedUserListAdapter

OpenChannelBannedUserListFragment

OpenChannelBannedUserListAdapter

MutedMemberListFragment

MutedMemberListAdapter

OpenChannelMutedParticipantListFragment

OpenChannelMutedParticipantListAdapter

OperatorListFragment

OperatorListAdapter

OpenChannelOperatorListFragment

OpenChannelOperatorListAdapter

ModerationFragment

ModerationAdapter

OpenChannelModerationFragment

OpenChannelModerationAdapter

MessageSearchFragment

MessageSearchAdapter

MessageThreadFragment

ThreadListAdapter

Customize adapter

Copy link

Below sample code shows how to create a customized message list adapter to not use the MessageGroupUI.

class CustomMessageListAdapter(
    channel: GroupChannel
) : MessageListAdapter(
    channel,
    MessageListUIParams.Builder()
        .setUseMessageGroupUI(false)
        .build()
)

Apply custom Adapters

Copy link

There are two ways to apply your custom adapters as shown below.

Set globally across the application

Copy link

This method sets the adapter globally so that it applies across the entire application. Each of the AdapterProviders provide the necessary arguments required for the adapter creation. It's recommended to set this up within the onCreate() method of your Application as shown in the code below.

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        AdapterProviders.messageList = MessageListAdapterProvider { channel, uiParams ->
            CustomMessageListAdapter(channel, uiParams)
        }
    }
}

Set in a specific fragment

Copy link

If you want different RecyclerView items for the same fragment instance, use the Builder interface of the specific fragment to set your custom adapter.

Note: Make sure to provide the necessary arguments directly during adapter creation when using this method.

val fragment = ChannelFragment.Builder(channelUrl)
   .setMessageListAdapter(CustomMessageListAdapter(channel, uiParams))
   .build()

For an in-depth practical demonstration, see our sample code.