How to show user name in the chat?
Hy,
I want to show user name in the chat like this:
without name it's hard to know who is chatting
Hi ahsengrw,
We are currently in the final stages of releasing an update to the Android code. This will bring the structure of the code in-line with the iOS code structure, we will also be adding some functionality. One additional piece of functionality will be names included in the chat screen.
If you want to implement this functionality yourself then I would recommend the following:
- Open the chat_sdk_row_text_message_friend.xml
You can see the current layout of the text cell. If you increase the size of the cell you can add a textView at the top to contain the user's name.
- Look at the ChatSDKMessagesListAdapter You can see that when we inflate the row we set the text content or image of the cell we are displaying. You would need to do a similar thing for your new name label.
You can then access the user who sent the message as this is a characteristic of the message object so you could then retrieve and add their name.
Simon
I already did this but failed to get name with extends BaseAdapeter activity (getNetworkAdapter().currentUserName().getMetaUser() cannot resolved in BaseAdapeter) . When I extends ChatSdkBaseActivity it works but notifydatasetchanged cannot resolved.
Hello,
Notify data set changed should not be getting called any more than before after implementing this change. When a new message is sent or received you should be adding the user name to the child views of the recycler upon creation. Then you will not have to worry about the data set updating.
Furthermore, the method you are calling for the user will only work for the user themselves, and may cause problems for the other labels. I would recommend using something more generic for all users in the chat.
Please note, for support with integrations and consulting we offer a priority support service. The github issues page is intended more for bugs and problems with the sdk.
If you are interested in the support please see the link above or our other services available at the chatsdk website.
-- Kyle
Hello,
I am wondering if you have had any luck with this customization. I would like to close the issue if the problem is solved.
-- Kyle
finally i solved the issue, thanks for the help!