mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 02:54:11 +08:00

_createNativeView to createNativeView; _initNativeView to initNativeView _disposeNativeView to disposeNativeView _resetNativeView to resetNativeView
32 lines
1.1 KiB
TypeScript
32 lines
1.1 KiB
TypeScript
import {
|
|
HtmlViewBase, htmlProperty
|
|
} from "./html-view-common";
|
|
|
|
export * from "./html-view-common";
|
|
|
|
export class HtmlView extends HtmlViewBase {
|
|
nativeView: android.widget.TextView;
|
|
|
|
public createNativeView() {
|
|
const textView = new android.widget.TextView(this._context);
|
|
// This makes the html <a href...> work
|
|
textView.setLinksClickable(true);
|
|
textView.setMovementMethod(android.text.method.LinkMovementMethod.getInstance());
|
|
return textView;
|
|
}
|
|
|
|
[htmlProperty.getDefault](): string {
|
|
return "";
|
|
}
|
|
[htmlProperty.setNative](value: string) {
|
|
// If the data.newValue actually has a <a...> in it; we need to disable autolink mask
|
|
// it internally disables the coloring, but then the <a> links won't work.. So to support both
|
|
// styles of links (html and just text based) we have to manually enable/disable the autolink mask
|
|
let mask = 15;
|
|
if (value.search(/<a\s/i) >= 0) {
|
|
mask = 0;
|
|
}
|
|
this.nativeView.setAutoLinkMask(mask);
|
|
this.nativeView.setText(<any>android.text.Html.fromHtml(value));
|
|
}
|
|
} |