至尊宝的传说
一个视图组可见或消失也可以放大,它不会对话。每次初始化情绪时,我总是使用像[happy] = R.drawable.happy这样的关键值。这是情感的文本而内容就像[快乐]public SpannableString textToImage(String content,Context c){
SpannableString ss = new SpannableString(content);
int starts = 0;
int end = 0;
if(content.indexOf("[", starts) != -1 && content.indexOf("]", end) != -1){
starts = content.indexOf("[", starts);
end = content.indexOf("]", end);
SharedPreferences shared=c.getSharedPreferences("emotion",0);
int resource=shared.getInt(content,0);
try {
Drawable drawable =c.getResources().getDrawable(resource);
if (drawable != null) {
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
ImageSpan span = new ImageSpan(drawable, ImageSpan.ALIGN_BASELINE);
ss.setSpan(span, starts,end + 1, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
}
} catch (Exception ex){
}
}
return ss;}