android string.xml reading html tags problem

前端 未结 4 1390
栀梦
栀梦 2020-11-29 03:44

In Android project\'s strings.xml file i have following html text







        
4条回答
  •  爱一瞬间的悲伤
    2020-11-29 04:38

    Directly passing the string resource id to setText() or using Context.getText() without Html.fromHtml() works properly but passing in the the result of Context.getString() does not.

    ex:

    strings.xml:

    
        This is bold and this is italic.
    
    

    code in Activity.java file:

    textView.setText(R.string.html); // this will properly format the text
    textView.setText(getText(R.string.html)); // this will properly format the text
    textView.setText(getString(R.string.html)); // this will ignore the formatting tags
    

提交回复
热议问题