想在EditText和TextView控件中随时插入手机本地图片,主要借助于android提供的两个类ImageSpan和SpannableString。如,在EditText中插入图片,分为3步:
1、扫描手机,选择图片:
Intent的Type设置为image/*表示任意格式的图片
private void choosePictureFromGallery() {
Intent intent = new Intent(Intent.ACTION_PICK);
intent.setType("image/*");
startActivityForResult(intent, CHOOSEPICTUREFROMGALLERY);
}
2、重写Activity的onActivityResult()方法:
case CHOOSEPICTUREFROMGALLERY:
if (data != null)