Android: html in strings.xml

后端 未结 5 1938
谎友^
谎友^ 2020-11-29 21:10

I would like display for example this html code:


    

Hello World

This is a test of the URL &

5条回答
  •  时光取名叫无心
    2020-11-29 22:02

    The best way to add html source code in strings.xml is to use . Here is an example:

    Text

    ]]>

    Then you can display this html in TextView using:

    myTextView.setText(Html.fromHtml(getString(R.string.html)));
    

    If you have links in your html and you want them to be clickable, use this method:

    myTextView.setMovementMethod(LinkMovementMethod.getInstance());
    

提交回复
热议问题