Android 2.3.3上的notifyDataSetChanged()异常行为
我正在实现一个聊天窗口。它在4.2 Emulator上运行良好,但在2.3.3 Emulator上运行时很奇怪。我已经实现了一个自定义适配器扩展BaseAdapter来填充ListVIew。ListView正在根据要显示的消息刷新有关项目的列表。Emulator 4.2正在根据需要刷新列表,但在2.3.3中,列表将使用最后选定的项刷新列表。下面是我的getView函数的代码Android 2.3.3上的notifyDataSetChanged()异常行为,android,listview,listviewitem,notifydatasetchanged,Android,Listview,Listviewitem,Notifydatasetchanged,我正在实现一个聊天窗口。它在4.2 Emulator上运行良好,但在2.3.3 Emulator上运行时很奇怪。我已经实现了一个自定义适配器扩展BaseAdapter来填充ListVIew。ListView正在根据要显示的消息刷新有关项目的列表。Emulator 4.2正在根据需要刷新列表,但在2.3.3中,列表将使用最后选定的项刷新列表。下面是我的getView函数的代码 public View getView(int position, View convertView, ViewGroup
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;
}
图片链接
仿真器4.2
仿真器2.3.3
谢谢屏幕截图在哪里?您可以上传屏幕截图并在此处粘贴链接。您的问题是什么?@AmulyaKhare很好的帮助:在适配器上调用notifyDataSetChanged时,尝试在列表视图上调用refreshDrawableState