大牛,聊天界面默认第一行和第二行消息怎么设置啊

goodcs 2014-09-11 03:12:18
业务是这样的:点击Button,进入聊天界面 默认显示 -----A(用户):我电脑坏了,你们能帮忙看看嘛? B(客服):谢谢咨询我们会尽快答复您!这里的A用户的信息是在点击Button的时候用Intent传过来的,
Intent intent = getIntent();
String firstLine=getIntent().getStringExtra("convsa");
cm.nickName=getIntent().getStringExtra("username");

// Log.v("_____________", "msg="+cm.chatMsg+"|nickName="+cm.nickName+"|userID="+cm.userID);
this.l_msg.add(cm);
if(null==chatMessageListAdapter){
chatMessageListAdapter = new ChatMessageListAdapter(firstLine, cm.nickName, l_msg, this);
lv_id.setAdapter(chatMessageListAdapter);
chatMessageListAdapter.notifyDataSetChanged();
}else{
chatMessageListAdapter.setL(l_msg);
chatMessageListAdapter.notifyDataSetChanged();
}

我的Adapter是这样写的
getView里面写第一条用户和第二条客服的信息
if(chatMessage.userID==0){
holder.rl_msg_friend.setVisibility(View.GONE);
holder.rl_msg_mine.setVisibility(View.VISIBLE);
holder.raiv_faceico_mine.setBackgroundResource(R.drawable.male);
if(position==0){
holder.tv_msg_content_mine.setText(firstLine);
}else{
holder.tv_msg_content_mine.setText(Html.fromHtml(content, imageGetter_resource, null));
}
//holder.tv_msg_content_mine.setText(Html.fromHtml(content, imageGetter_resource, null));
//holder.tv_msg_content_mine.setText(content);
// holder.tv_mine_nickname.setText(chatMessage.nickName);
holder.tv_mine_nickname.setText(myname);
}else{
holder.rl_msg_friend.setVisibility(View.VISIBLE);
holder.rl_msg_mine.setVisibility(View.GONE);
holder.raiv_faceico_friend.setBackgroundResource(R.drawable.female);
if(position==1){
holder.tv_msg_content_friend.setText("Thanks for contacting us, we will contact you as soon as possible");
}else{
holder.tv_msg_content_friend.setText(Html.fromHtml(content, imageGetter_resource, null));
}
我的是这样的每次进入聊天界面不显示上面第一条和第二条信息,当我在聊天界面输入两条消息点击send后才显示上面客户和客服的消息,而此时我自己输入的两条消息木有显示,也就是被希望默认进入聊天界面的两条消息代替了,而我希望是不需要自己输入,进入聊天界面就显示用户A和客服B的那两条消息,帮忙看看是哪个地方的逻辑问题啊?谢谢!
...全文
117 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
荔枝别闹了 2014-09-11
  • 打赏
  • 举报
回复
传代码的话用那个插入代码的东西,别直接复制上来。。。
goodcs 2014-09-11
  • 打赏
  • 举报
回复
补充一下 模拟操作的信息: 在position==0时候firstLine获取的资源就是客服A:我电脑坏了,你们能帮忙看看嘛? 在position==1时候设置的消息是Thanks for contacting us, we will contact you as soon as possible 即:B(客服):谢谢咨询我们会尽快答复您!

80,352

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧