I am implementing a chat window. It is working fine on 4.2 Emulator but weird acting on 2.3.3 Emulator. I have implemented a custom Adapter
extending BaseAdapter
to populate the ListVIew
. ListView
is refreshing the list respecting items
base on who's message to display. Emulator 4.2 is refreshing the list as desired but on 2.3.3 list refreshes the with last selected item. Here is the code for my getView
function.
public View getView(int position, View convertView, ViewGroup parent) {
View chatItem = convertView;
if (chatItem == null) {
if (position % 2 == 0) //TODO: Change it to arrayListChat.getUpdater
chatItem = ((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.chat_item_me, parent, false);
else
chatItem = ((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.chat_item_support, parent, false);
ChatListItemViewHolder viewHolder = new ChatListItemViewHolder();
viewHolder.textViewChat = (TextView) chatItem.findViewById(R.id.textViewChat);
chatItem.setTag(viewHolder);
}
ChatListItemViewHolder viewHolder = (ChatListItemViewHolder) chatItem.getTag();
viewHolder.textViewChat.setText(arrayListChat.get(position).getMessage());
return chatItem;
}
Link for the images
Emulator 4.2 https://i.stack.imgur.com/qfOgJ.png
Emulator 2.3.3 https://i.stack.imgur.com/7tLCT.png
Thanks