Reputation: 198
I have multiple items in my chatListLinearLayout, I would like to update my messageStatus to say something such as "Item selected" for the selected item. I managed to do this successfully but I would like to save this so the next time the user reopens the app it will remain.Could someone assist me?
displayMessagesRecycleView.addOnItemTouchListener(new RecyclerItemClickListener(getContext(), new RecyclerItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, final int position) {
CircleImageView profileImage = view.findViewById(R.id.users_profile_image);
LinearLayout chatListLinearLayout = view.findViewById(R.id.chatListLinearLayout);
final TextView messageStatus = view.findViewById(R.id.user_status);
chatListLinearLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
messageStatus.setText("Item selected");
}
});
Upvotes: 0
Views: 91
Reputation: 195
You can setSelected(true);
for view and set one boolean in you object model
and for save selected item state you need to save your list into sharedPrefs or sqlite database
Upvotes: 1