新しいアクティビティを開始させるために、TextViewへのリンクを挿入しようとしています。Utils
私はそれを行うためにクラスにメソッドを書きました:
public static final String tagPattern = "#([^ ]+)";
public static final String tagReplace = "<a href=\"org.openihs.seendroid://display/tag/$1/\">#$1</a>";
public static final String userPattern = "@([^ ]+)";
public static final String userReplace = "<a href=\"org.openihs.seendroid://display/user/$1/\">@$1</a>";
static public void linkify(TextView view) {
String text = view.getText().toString();
text = text.replaceAll(Utils.tagPattern, Utils.tagReplace);
text = text.replaceAll(Utils.userPattern, Utils.userReplace);
view.setMovementMethod(LinkMovementMethod.getInstance());
view.setText(Html.fromHtml(text));
Log.d("SeenDroid", text);
Linkify.addLinks(view, Linkify.ALL);
}
(logcatへの)出力例は次のとおりです。
foo <a href="org.openihs.seendroid://display/tag/bar/">#bar</a> baz http://google.fr/
また、実際のUIはhttp://google.fr/をリンク(予期される動作)として提供しますが#bar
、通常のテキスト(予期しない動作)として提供します。
TextViewはListViewにあります。
その問題を解決するためのアイデアはありますか?
よろしく、ProgVal