我如何在带有 String 的 AlertDialog 中制作 String + URL 并且 URL 是可点击的

How i make String + URL in AlertDialog with String is not clickable and URL is clickable

我正在显示警报对话框,其中我有 "Terms & Conditions",最后有文本,我想在其上单击以获取 URL。 我不想在字符串中显示 URL 而不是 URL 我想以不同的颜色或大小显示字符串以了解用户。

AlertDialog.Builder builder = new AlertDialog.Builder(this);
   builder.setTitle("My App Title");
   builder.setPositiveButton(R.string.next,
     new DialogInterface.OnClickListener() {
      @Override
      public void onClick(DialogInterface dialog, int id) {
       // code goes here

       User u = new User();
       u.setTncAccpted(true);
       u.setFirstRun(true);
       u.commit(SelectionApp.this);
       viewedWeb = false;
       dialog.dismiss();
      }

     });
   try {
    builder.setMessage(Html
    .fromHtml("<p>My Text is going here....</p><p>My other String is going here....</p>By proceeding you are accepting <a href=\"\">Terms and Conditions.</a>"));

    AlertDialog dialog = builder.create();
    if (dialog == null)
     return;
    dialog.show();
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);
((TextView) dialog.findViewById(android.R.id.message))
  .setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {
   // TODO Auto-generated method stub

    Intent termAndConditionIntent = new Intent(
    SelectionWhiteApp.this, ViewWeb.class);
    startActivity(termAndConditionIntent);
       }
      });

   } catch (Exception e) {
    // TODO: handle exception
   }

现在我的整个文本是可点击的,但我只想 "Terms and Conditions" 可点击,当它点击打开特定的 link。

我不确定它是否有效,但你可以试试这个

text.setText(Html.fromHtml("<bMy Text is going here....</b>" +
                "<a href=\"http://www.example.com\">Terms and Conditions.</a> "));
 text.setMovementMethod(LinkMovementMethod.getInstance());