【求教】ImageSpan顯示異常

首先我把EditText中的內容發送到服務器中保存,在EditText中ImageSpan顯示正常:html

<!-- lang: java -->
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文本是這樣的:java

<!-- lang: html -->
<p dir="ltr">1234567123<img src="android.resource://mypackage/2130837510">1238912<img src="android.resource://mypackage/2130837510"></p>

而後,我試圖在ListView中顯示剛剛發送到文本:android

<!-- lang: java -->
viewgroup.textview1.setText(Html.fromHtml(item_list.get(position)), TextView.BufferType.SPANNABLE);

可是此時顯示的ImageSpan卻變成了方塊。求大牛指教! 在此輸入圖片描述服務器

相關文章
相關標籤/搜索