Android TextView : “Do not concatenate text displayed with setText”

前端 未结 10 1539
小鲜肉
小鲜肉 2020-12-02 04:01

I am setting text using setText() by following way.

prodNameView.setText(\"\" + name);

prodOriginalPriceView.setText(\"\" + String.format(g         


        
10条回答
  •  甜味超标
    2020-12-02 04:51

    the problem is because you are appending "" at the beginning of every string.

    lint will scan arguments being passed to setText and will generate warnings, in your case following warning is relevant:

    Do not build messages by concatenating text chunks. Such messages can not be properly translated.

    as you are concatenating every string with "".

    remove this concatenation as the arguments you are passing are already text. Also, you can use .toString() if at all required anywhere else instead of concatenating your string with ""

提交回复
热议问题