android 在EditText中显示表情图片
2013-08-14 11:57
330 查看
public class MainActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); EditText editText=(EditText) this.findViewById(R.id.edittext); //src中的图片的名字必须在drawable中存在该图片 String html="<img src='sleep'>"; CharSequence text=Html.fromHtml(html, new ImageGetter() { public Drawable getDrawable(String source) { Drawable drawable=getResources().getDrawable(getImageID(source)); drawable.setBounds(0, 0, drawable.getIntrinsicWidth()/3, drawable.getIntrinsicHeight()/3); return drawable; } }, null); editText.setText(text); } /* * * 获取图片资源的ID */ public int getImageID(String name) { try { Field field=R.drawable.class.getField(name); return Integer.valueOf(field.getInt(name)); } catch (Exception e) { e.printStackTrace(); } return 0; } }
相关文章推荐
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- android TextView和EditText中显示图片
- Android之TextView、EditText控件显示表情图片
- 在EditText和TextView显示表情图片(类似QQ表情)
- Android EditText显示图片的两种方法
- 在EditText中插入表情图片 (CharacterStyle&SpannableString),TextView中显示HTML和图片
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- Android EditText中插入图片,比如做表情发送
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- 在EditText中插入表情图片 (CharacterStyle&SpannableString),TextView中显示HTML和图片
- Android EditText加入图片混编显示
- android TextView和EditText中显示图片
- Android中实现Edittext中输入表情图片的方法
- android的EditText里文字和图片混合编辑与显示
- Android设置EditText显示输入的表情Icon(自定义的聊天有个发送表情功能,在输入框显示表情)
- android edittext,listview里面显示gif动态表情
- android TextView和EditText中显示图片
- Android的TextView/EditText使用CharacterStyle&SpannableString来处理图片显示、字体样式、超链接等
- Android TextView、EditText显示表情 推荐