我已經啓動了一個定時器,它調用了getMessage webservice,它返回該用戶的通訊消息arraylist的大小總是顯示正確的消息數量,但是當在該消息的列表視圖中顯示時只顯示最後一個消息發送給web服務我已經使用此代碼。爲什麼在listview中總是顯示arraylist的最後一個值?
public void handleMessage(Message msg)
{
super.handleMessage(msg);
if(msg.arg1!=RECIEVEFAILURE)
{
objrReceiveMessageSiteList =(ArrayList<ReceiveMessageSiteList>)msg.obj;
System.out.println("objrReceiveMessageSiteList.get(0)"+objrReceiveMessageSiteList.get(0).getMessageStatus());
System.out.println("objrReceiveMessageSiteList.get(0)"+objrReceiveMessageSiteList.size());
if(objrReceiveMessageSiteList.size()!=0 && !objrReceiveMessageSiteList.get(0).getMessageStatus().equalsIgnoreCase("No New Message"))
{
for(int i=0;i<objrReceiveMessageSiteList.size();i++)
{
objkeyvaluepair.setMessage(objrReceiveMessageSiteList.get(i).getMessage());
objkeyvaluepair.setMessageType(objrReceiveMessageSiteList.get(i).getMessageType());
objkeyvaluepair.setTimeStamp(objrReceiveMessageSiteList.get(i).getTimeStamp());
objkeyvaluepair.setSenderFirstName(objrReceiveMessageSiteList.get(i).getSenderFirstName());
objkeyvaluepair.setSenderId(objrReceiveMessageSiteList.get(i).getSenderId());
objkeyvaluepair.setRecieverFirstName(objrReceiveMessageSiteList.get(i).getReceiverFirstName());
messagerecord.add(objkeyvaluepair);
System.out.println("MESSAGE SIZE"+messagerecord.size());
System.out.println("MESSAGE---------- findeee"+messagerecord.get(i).getMessage());
}
System.out.println("objrReceiveMessageSiteList.get(0)--------------"+objrReceiveMessageSiteList.get(0).getMessageStatus());
message.setText(""+messagerecord.size());
}
}
}
};
這裏面for循環的ArrayList適配器設置適配器發送時是表示syste.out.println.but正確的信息採取合適的尺寸,但所有的列表只顯示最後的消息view.please幫我