外部と内部のリンク (ページ ナビゲーション) を含む HTML のテキストがあります。このテキストを Html.fromHtml で使用して TextView に表示すると、外部リンクは機能しますが、ページ自体の内部では機能しません。私はすでに setMovementMethod と Linkify の両方を試しましたが、すべてが正しくありません。WebView で機能することはわかっていますが、この方法で作業する方がはるかに高速で便利です。
コードサンプル:
private void showText(String text) {
TextView content = view.findViewById(R.id.textContent);
content.setText(Html.fromHtml(text, FROM_HTML_MODE_COMPACT));
content.setMovementMethod(LinkMovementMethod.getInstance());
}
テキストのサンプル:
The text is long, contained in a ScrollView, has <a name="sdfootnoteAanc" href="#sdfootnoteAsym"> links </a> within itself, such as footnotes. When pressed, the text should scroll to <a name="sdfootnoteAsym" href="#sdfootnoteAanc"> link location </a>, and then back - as often happens on sites.