我正在尝试将图像插入EditText
,我的图像ID存储在整数列表中...
我显示一个包含所有笑容的GridView
,当用户选择笑脸时,我使用方法:
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
并将索引传递给ID列表,然后获取ID,并将其发布到FromHtml:
这里是代码:
gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
int p;
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
p=i;
Html.ImageGetter imgg= new Html.ImageGetter() {
public Drawable getDrawable(String source) {
Log.d("SOMAA","source= "+source);
Log.d("SOMAA","Arrived index = "+p);
Log.d("SOMAA","ID = "+SmilesList[p]);
Drawable d = Massenger_frag.this.getResources().getDrawable(SmilesList[p]);
if (d != null) {
d.setBounds(0,0,d.getIntrinsicWidth(),d.getIntrinsicHeight());
}
Log.d("SOMAA","d = "+d);
return d;
}
};
indexSmile=i;
Log.d("SOMAA","index = " + i+ " OR "+ indexSmile);
// ImageView imv= (ImageView) view.findViewById(SmilesList[indexSmile]);
Spanned smiletxt = Html.fromHtml("<img src='" + getResources().getDrawable(SmilesList[indexSmile])+"'/>",imgg,null);
Log.d("SOMAA","Smile text= "+smiletxt);
EditText msgt = (EditText) getView().findViewById(R.id.MessageInMessanger);
String str = msgt.getText().toString();
str+= smiletxt;
msgt.setText(str);
}
});
问题是: 而不是微笑,我在EditText ....中看到了symbole [obj]。
为什么呢?我该如何解决这个问题呢!