我在适配器中有自定义 listView 项目和自定义 arrayAdapter
我使用 viewHolder 使 listView 平滑滚动,但是当我滚动列表时,listView 中的项目是混合的
,所以我认为应该再次创建项目,现在我如何释放或回收以前创建的项目项目清单?
这是我的 arrayAdapter 的 getview 代码:
public View getView(final int position, View convertView, ViewGroup parent)
{
ViewHolder holder;
View v = convertView;
//final ILSpeechBubble speechBubble;
if(v == null)
{
inflater = context.getLayoutInflater();
if(m_msg.get(position).Recieved == 0)
{
v = inflater.inflate(R.layout.text_message_sent_row_template, null);
holder = new ViewHolder();
holder.spBubble = (ILSpeechBubble) v.findViewById(R.id.iLSpeechBubble1);
holder.imgProfilePic = (ImageView) v.findViewById(R.id.imgProfilePic);
holder.imgSend = (ImageView) v.findViewById(R.id.imgMessageSent);
holder.imgDeliverd = (ImageView) v.findViewById(R.id.imgMessageDeliverd);
holder.pbSending = (ProgressBar) v.findViewById(R.id.pbSendingMessage);
holder.spBubble.isChache = false;
v.setTag(holder);
}
else
{
v = inflater.inflate(R.layout.text_message_recieved_row_template, null);
holder = new ViewHolder();
holder.spBubble = (ILSpeechBubble) v.findViewById(R.id.iLSpeechBubble1);
holder.imgProfilePic = (ImageView) v.findViewById(R.id.imgProfilePic);
holder.spBubble.isChache = false;
v.setTag(holder);
}
}
else
{
holder = (ViewHolder) v.getTag();
holder.spBubble.isChache = true;
//return v;
}