在开发过程遇到需要在TextView上显示文字+图片。
因为数据返回是 <img src='js\image1'/> 这类格式的。
所以。
CharSequence charSequence = Html.fromHtml(html, new Html.ImageGetter() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public Drawable getDrawable(String source) {
****
通过这个方法拿到资源,由TextView进行展示。} }, null);
但是在拿 Drawable 的过程中,报了一个错。
Drawable drawable = mContext.getDrawable(getResourceId(subFileName(source)));
java.lang.NoSuchMethodError:android.content.Context.getDrawable
中文网查到貌似没有信息,还是看漏了,于是上 stackoverflow.看查。
原帖如下:
http://stackoverflow.com/questions/27796246/android-alternative-for-context-getdrawable
ContextCompat.getDrawable(context, R.drawable.***);