0

这是一个可用性问题

我曾经LinkMovementMethod.getInstance()允许 textview 滚动和 URLS 可点击(打开浏览器),问题是这会造成混乱,当用户在链接上释放滚动时,它会自动打开 Google Chrome 浏览器,而不是什么都不做。每个滚动打开的浏览器(因为有很多链接)。

所以,在打开浏览器之前,我想显示一个对话框询问“你想打开链接吗?”,我尝试了很多,但我无法识别任何听众

其他解决方案是仅当 CLICK 和 RELEASE 在同一个链接中执行时才打开浏览器(在这种情况下更能保证用户没有进行任何滚动)

我也愿意接受其他建议

你可以看到很多链接

在此处输入图像描述

XML 简要介绍:

<etc.TextViewCustomizado
    android:layout_width="match_parent"
    app:nomeFonte="Cairo_Regular"
    android:textSize="17sp"
    android:id="@+id/textview"
    android:textColor="@android:color/black"
    android:textColorLink="@color/azul2escuro"
    android:layout_height="match_parent" />

因此,如您所见,它只是一个包含所有信息的文本视图,通过以下方式传递:

textview.setText(Html.fromHtml(
       getResources().getString(R.string.lic1)
));
textview.setMovementMethod(LinkMovementMethod.getInstance());

资源R.string.lic

<![CDATA[

    Programming libraries (Linguagens de programação)

    <br>

    <a href="https://github.com/rengwuxian/MaterialEditText">MaterialEditText</a>
    by
    <a href="https://github.com/rengwuxian">rengwuxian</a>
    licensed under
    <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>

    ..continues

谢谢

4

1 回答 1

0

我找到了一个替代方案,使用 WebView

XML:

<LinearLayout
    ...>

    <WebView
        android:id="@+id/wv"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
    />
</LinearLayout>

活动:

private WebView wv = (WebView) findViewById(R.id.wv);
wv.loadData(getResources().getString(R.string.lic1), "text/html; charset=utf-8",null);
于 2018-04-18T16:21:54.513 回答