【问题标题】:Android - LinkMovementMethod.getInstance() open automatically browser when user release scroll on a linkAndroid - 当用户在链接上释放滚动时,LinkMovementMethod.getInstance() 会自动打开浏览器
【发布时间】:2018-02-07 21:40:44
【问题描述】:

这是一个可用性问题

我使用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

谢谢

【问题讨论】:

    标签: android usability fromhtml linkmovementmethod


    【解决方案1】:

    我找到了一个替代方法,使用 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);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-11-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多