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