本文整理汇总了Java中android.text.Html.ImageGetter方法的典型用法代码示例。如果您正苦于以下问题:Java Html.ImageGetter方法的具体用法?Java Html.ImageGetter怎么用?Java Html.ImageGetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.text.Html
的用法示例。
在下文中一共展示了Html.ImageGetter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setHtml
import android.text.Html; //导入方法依赖的package包/类
/**
* Parses String containing HTML to Android's Spannable format and displays it in this TextView.
* Using the implementation of Html.ImageGetter provided.
*
* @param html String containing HTML, for example: "<b>Hello world!</b>"
* @param imageGetter for fetching images. Possible ImageGetter provided by this library:
* HtmlLocalImageGetter and HtmlRemoteImageGetter
*/
public void setHtml(@NonNull String html, @Nullable Html.ImageGetter imageGetter) {
final HtmlTagHandler htmlTagHandler = new HtmlTagHandler(getPaint(), imageClick);
htmlTagHandler.setClickableTableSpan(clickableTableSpan);
htmlTagHandler.setDrawTableLinkSpan(drawTableLinkSpan);
html = htmlTagHandler.overrideTags(html);
if (removeFromHtmlSpace) {
setText(removeHtmlBottomPadding(Html.fromHtml(html, imageGetter, htmlTagHandler)));
} else {
setText(Html.fromHtml(html, imageGetter, htmlTagHandler));
}
// make links work
setMovementMethod(LocalLinkMovementMethod.getInstance());
}
示例2: setHtml
import android.text.Html; //导入方法依赖的package包/类
/**
* Parses String containing HTML to Android's Spannable format and displays it in this TextView.
* Using the implementation of Html.ImageGetter provided.
*
* @param html String containing HTML, for example: "<b>Hello world!</b>"
* @param imageGetter for fetching images. Possible ImageGetter provided by this library:
* HtmlLocalImageGetter and HtmlRemoteImageGetter
*/
public void setHtml(@NonNull String html, @Nullable Html.ImageGetter imageGetter) {
final HtmlTagHandler htmlTagHandler = new HtmlTagHandler(getPaint());
htmlTagHandler.setClickableTableSpan(clickableTableSpan);
htmlTagHandler.setDrawTableLinkSpan(drawTableLinkSpan);
html = htmlTagHandler.overrideTags(html);
if (removeTrailingWhiteSpace) {
setText(removeHtmlBottomPadding(Html.fromHtml(html, imageGetter, htmlTagHandler)));
} else {
setText(Html.fromHtml(html, imageGetter, htmlTagHandler));
}
// make links work
setMovementMethod(LocalLinkMovementMethod.getInstance());
}
示例3: obtainImageGetter
import android.text.Html; //导入方法依赖的package包/类
private Html.ImageGetter obtainImageGetter() {
if (_imageGetter != null) {
return _imageGetter;
}
_imageGetter = new Html.ImageGetter() {
@Override
public Drawable getDrawable(String source) {
if (_imageCache == null) {
_imageCache = new XulCachedHashMap<String, SpannedLabelImage>();
}
SpannedLabelImage spannedLabelImage = _imageCache.get(source);
if (spannedLabelImage == null) {
spannedLabelImage = new SpannedLabelImage();
spannedLabelImage._source = source;
_imageCache.put(source, spannedLabelImage);
_imageCacheChanged = true;
}
if (spannedLabelImage._drawable == null) {
return null;
}
return spannedLabelImage._drawable;
}
};
return _imageGetter;
}