Pinned Message List
PinnedMessageListView
is a UI Component that shows a list of pinned messages.
Light Mode | Dark Mode |
---|---|
Usage
You can add this View via XML:
<io.getstream.chat.android.ui.feature.pinned.list.PinnedMessageListView
android:id="@+id/pinnedMessageListView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
We recommend using this view with its ViewModel, which supplies it with data from the Stream API.
The basic setup of the ViewModel and connecting it to the View is done the following way:
- Kotlin
- Java
val viewModel: PinnedMessageListViewModel by viewModels {
PinnedMessageListViewModelFactory(cid = "messaging:123")
}
viewModel.bindView(pinnedMessageListView, viewLifecycleOwner)
ViewModelProvider.Factory factory = new PinnedMessageListViewModelFactory.Builder()
.cid("messaging:123")
.build();
PinnedMessageListViewModel viewModel = new ViewModelProvider(this, factory).get(PinnedMessageListViewModel.class);
PinnedMessageListViewModelBinding.bind(viewModel, pinnedMessageListView, getViewLifecycleOwner());
From that point, you should be able to see the list of pinned messages.
note
bindView
sets listeners on the View and the ViewModel. Any additional listeners should be set after calling bindView
.
Handling Actions
PinnedMessageListView
allows you to configure certain actions on it:
- Kotlin
- Java
pinnedMessageListView.setPinnedMessageSelectedListener { message ->
// Handle a pinned message item being clicked
}
pinnedMessageListView.setPinnedMessageSelectedListener(message -> {
// Handle a mention item being clicked
});
The full list of available listeners is available here.