Customize list adapters
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
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
The following table shows a list of all fragments and its corresponding adapters.
Fragment | Adapter |
---|---|
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
Below sample code shows how to create a customized message list adapter to not use the MessageGroupUI
.
Apply custom Adapters
There are two ways to apply your custom adapters as shown below.
Set globally across the application
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.
Set in a specific fragment
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.
For an in-depth practical demonstration, see our sample code.