【问题标题】:Unable to get links identified in a message string along with link preview in TextView无法获取消息字符串中标识的链接以及 TextView 中的链接预览
【发布时间】:2018-12-22 04:11:05
【问题描述】:

我正在开发一个聊天应用程序。在这种情况下,当用户从某处复制文本并尝试粘贴 EditText 并使用发送按钮发送它时。未识别文本中的链接。当我将 textview 设置为可点击和 android:autoLink="web"。

它仍然无法正常工作,我也没有得到如下链接的预览:

帮助,希望如何继续。谢谢!

【问题讨论】:

    标签: android firebase android-studio firebase-realtime-database android-recyclerview


    【解决方案1】:

    这里是html链接:

    TextView textView = findViewById(R.id.text_view);
    Spanned spanned = Html.fromHtml("your html string");
    textView.setText(spanned, TextView.BufferType.SPANNABLE);
    textView.setMovementMethod(LinkMovementMethod.getInstance());
    

    确保您没有android:autoLink="web" https://stackoverflow.com/a/15299208/1329854

    对于丰富的链接预览检查这个答案:
    https://stackoverflow.com/a/38217502/1329854

    【讨论】:

      猜你喜欢
      • 2016-12-23
      • 2013-03-24
      • 1970-01-01
      • 2011-07-28
      • 1970-01-01
      • 2016-03-28
      • 1970-01-01
      • 2020-07-27
      • 2011-06-15
      相关资源
      最近更新 更多