【求教】ImageSpan显示异常

flybywind 发布于 2013/05/06 10:46
阅读 794
收藏 0
首先我把EditText中的内容发送到服务器中保存,在EditText中ImageSpan显示正常:

Uri img_uri = Uri.parse("android.resource://mypackage/" + R.drawable.emotion_smile);
ImageSpan imageSpan = new ImageSpan(editor_activity, img_uri);
int insert_loc = mEditorBody.getSelectionStart();
span_builder.insert(insert_loc, "`a`");
span_builder.setSpan(imageSpan, insert_loc, insert_loc+3, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
mEditorBody.setText(span_builder);
mEditorBody.setSelection(insert_loc+1);  

HttpClient client = new DefaultHttpClient();
HttpPost post_req = new HttpPost(SERVER);
ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();

text_body = mEditorBody.getText();
nameValuePairs.add(new BasicNameValuePair("content", Html.toHtml(text_body)));

try {
    post_req.setEntity(new UrlEncodedFormEntity(nameValuePairs, HTTP.UTF_8));
    response = client.execute(post_req);
}
其中发送到服务器的html文本是这样的:
    <p dir="ltr">1234567123<img src="android.resource://mypackage/2130837510">1238912<img src="android.resource://mypackage/2130837510"></p> 
然后,我试图在ListView中显示刚刚发送到文本:
    viewgroup.textview1.setText(Html.fromHtml(item_list.get(position)), TextView.BufferType.SPANNABLE); 
但是此时显示的ImageSpan却变成了方块。求大牛指教!

加载中
返回顶部
顶部