1
我正在研究android聊天應用程序。我在使用xmpp發送和接收函數時遇到問題。我能夠從模擬器發送消息到xmpp並從xmpp接收消息。但我在列表視圖中顯示傳入和傳出消息時遇到問題。我很困惑如何給條件設置視圖佈局。從xmpp動態數據的列表視圖
if(message from xmpp) {
TextView textLabel = (TextView) row.findViewById(R.id.textb); // if message received dislay in left side textview
textLabel.setText(receiveddata); //receiveddata contains arraylist of incoming message
} else (message from me) {
TextView textLabel = (TextView) row.findViewById(R.id.texts); // if message sent by me dislay in right side textview
textLabel.setText(sentdata); //sentdata contains arraylist of outgoing message
}
請告訴我,我怎麼能做到這一點。
謝謝
getItemViewType在android docs.Check中檢查它的類型。如果可以在getView中將其轉換爲另一個視圖,則兩個視圖應共享相同的類型。注:整數必須在0到getViewTypeCount - 1之間。IGNORE_ITEM_VIEW_TYPE也可以返回。 – 2012-03-28 11:22:58