本文整理匯總了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;
}