0

在我的溢出菜单中,我有一个显示关于信息的弹出窗口。它工作正常,但我想在我的网站上添加一个可点击的链接,但我无法让它工作。到目前为止的代码是:

         case R.id.about:
              LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View popupView = inflater.inflate(R.layout.about_dialog, null);
              PopupWindow pw = new PopupWindow(popupView, width, width, true);
              TextView link = (TextView)findViewById(R.id.urlLink);
              link.setMovementMethod(LinkMovementMethod.getInstance());
              pw.showAtLocation(new LinearLayout(this), Gravity.CENTER, 0, 0);
          return true;

我在资源中定义了一个字符串:

<resources>
    <string name="webLink"><a href="www.google.com">www.google.com</a></string>
</resources>

XML 本身的块是:

 <TextView
        android:id="@+id/urlLink"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:textSize="24sp"
        android:textStyle="bold"
        android:gravity="center"
        android:text="@string/webLink" />

当它到达 setMovementMethod 行时,它似乎崩溃了。

谁能看到我错过了什么?谢谢和最良好的祝愿托尼雷诺兹

4

1 回答 1

0

我提出这个答案是为了表明 Mike M 的评论已经解决了这个问题。

于 2021-08-06T16:11:20.600 回答