Bubble Chat issue Android listview

瘦欲@ 提交于 2019-12-02 02:55:28

You have not organised your chat data properly. Have a class that holds a chat message and its sender id.

class Message {
   int senderId;
   String message;
}

Use this object to create the list of chat messages. Then in adapter's getview method do this

Message msg = messageList.get(position);
if (msg.getSenderId() == getMyId()) { // if its the message sent by me?
    // inflate right side layout.
else 
    // inflate left side layout.
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!