private TextView text;
private List<String> list;
private String html="<html><head><title>TextView使用HTML</title></head><body><p><strong>强调</strong></p><p><em>斜体</em></p>"
+"<p><a href=\"http://www.dreamdu.com/xhtml/\">超链接HTML入门</a>学习HTML!</p><p><font color=\"#aabb00\">颜色1"
+"</p><p><font color=\"#00bbaa\">颜色2</p><h1>标题1</h1><h3>标题2</h3><h6>标题3</h6><p>大于>小于<</p><p>" +
"下面是网络图片</p><img src=\"http://b.hiphotos.baidu.com/image/w%3D310/sign=31473635ed24b899de3c7f395e061d59/0b46f21fbe096b63ef5b426508338744ebf8ac40.jpg\"/></body></html>";
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
ViewGroup viewGroup = null;
return inflater.inflate(R.layout.fragment2, viewGroup);
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
text = (TextView) getView().findViewById(R.id.web);
text.setText(Html.fromHtml(html, new ImageGetter() {
@Override
public Drawable getDrawable(String source) {
return null;
}
}, null));
}
Html.ImageGetter imageGetter = new Html.ImageGetter() {
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());
Log.d("---------bounds", drawable.getBounds()+"");
return drawable;
}
};
这是我的代码 图片不会显示 并且log “---------------bounds” 也不会打印 也就是 没有执行这个getDrawble吧 求解
------解决思路----------------------
肯定catch到错误了,debug看看不就知道了