Android编程实现QQ表情的发送和接收完整实例(附源码下载)

2019-12-10 19:53:57王旭
  • return spannableString;   }  
  • 在显示聊天页面的list的适配器中,我们需要做如下的显示,即调用上面工具类的方法:

    SimpleChatAdapter中的内部类ViewHolder:

     

     
    1. private class ViewHolder{   RelativeLayout chat_layout;  
    2. ImageView image;   TextView text;  
    3. public ViewHolder(View convertView){   chat_layout=(RelativeLayout) convertView.findViewById(R.id.team_singlechat_id_listiteam);  
    4. image=(ImageView) convertView.findViewById(R.id.team_singlechat_id_listiteam_headicon);   text=(TextView) convertView.findViewById(R.id.team_singlechat_id_listiteam_message);  
    5. }   public void setData(MessageInfo msg){  
    6. RelativeLayout.LayoutParams rl_chat_left=((RelativeLayout.LayoutParams)chat_layout.getLayoutParams());   RelativeLayout.LayoutParams rl_tv_msg_left=((RelativeLayout.LayoutParams)text.getLayoutParams());  
    7. RelativeLayout.LayoutParams rl_iv_headicon_left=((RelativeLayout.LayoutParams)image.getLayoutParams());   if(!DicqConstant.DEFAULTMAC.equalsIgnoreCase(msg.getUsermac())){ //根据本地的mac地址来判断该条信息是属于本人所说还是对方所说  
    8. //如果是自己说的,则显示在右边;如果是对方所说,则显示在左边   rl_chat_left.addRule(RelativeLayout.ALIGN_PARENT_LEFT,-1);  
    9. rl_chat_left.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0);   rl_iv_headicon_left.addRule(RelativeLayout.ALIGN_PARENT_LEFT,-1);  
    10. rl_iv_headicon_left.addRule(RelativeLayout.ALIGN_PARENT_RIGHT,0);   rl_tv_msg_left.addRule(RelativeLayout.RIGHT_OF,R.id.team_singlechat_id_listiteam_headicon);