码迷,mamicode.com
首页 > 移动开发 > 详细

Android 用TextView显示超链接、图片

时间:2015-04-18 16:04:27      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:

ImageGetter imgGetter = new Html.ImageGetter() {
        @Override
        public Drawable getDrawable(String source) {
            Drawable drawable = null;
            URL url;
            try {
                url = new URL(source);
                drawable = Drawable.createFromStream(url.openStream(), "");
            } catch (Exception e) {
                return null;
            }
            drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
                    drawable.getIntrinsicHeight());
            return drawable;
        }
    };

txtContent.setText(Html.fromHtml(entity.getNewsContent(), imgGetter,
    null));

Android 用TextView显示超链接、图片

标签:

原文地址:http://www.cnblogs.com/leichentao0905/p/4437450.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!