工作内容:
socket手机端客户端设计
遇到问题:
1.在编辑框中发送表情
2.在点击发送按钮时要:编辑框失去焦点,键盘消失
3.链接上socket服务器
一、实现在TextView,EditText中添加表情(图片)
/**
* 1.定义一个位图
* 2.将字符串对象改变成一个图像
* 3.把图像加载到TextView、EditText中
*/
//定义一个位图
Bitmap bitmap = BitmapFactory.decodeResource(getResources(),R.drawable.group_blue);
//定义一个可以输入EditText的对象
SpannableString spannableString = newSpannableString("face1");
//将对象更改成一个图像
ImageSpan imageSpan = new ImageSpan(MainActivity.this,bitmap);
spannableString.setSpan(imageSpan,0,5,SpannableString.SPAN_EXCLUSIVE_EXCLUSIVE);
textView.append(spannableString);
....
edit.setText(""); //清空编辑框
edit.clearFocus(); //让编辑框失去焦点
//利用InputMethodManager的hideSoftInputFromWindow()方法让编辑框对应的输入键盘消失 InputMethodManager imm = (InputMethodManager)getSystemService(Chat.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(edit.getWindowToken(),0); textView.scrollTo(0,textView.getBottom());