0

I have a String resource containing my disclaimer Text. I use it in a Dialog:

    private void showDisclaimer() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Disclaimer")
            .setIcon(android.R.drawable.ic_dialog_info)
            .setMessage(getString(R.string.disclaimer)).setCancelable(true)
            .setNegativeButton("OK", new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();


                }
            });

    AlertDialog alert = builder.create();
    alert.show();

}

I want to make certain parts clickable and use them as http links. I tried the following but HTML markup seems to have no effect:

  <string name="disclaimer"> ...some things are trademarks of <a href="http://google.com/">Google</a> ................. </string>

Any suggestions?

Droidman
  • 11,485
  • 17
  • 93
  • 141

1 Answers1

1

Do it like this:

<string name="disclaimer"><![CDATA[some things are trademarks of <a href="http://google.com/">Google</a>]]> </string>

and call

getResources().getText(R.string.disclaimer); 

or

Html.fromHtml(getString(R.string.disclaimer));
M-Wajeeh
  • 17,204
  • 10
  • 66
  • 103