What is the difference between textView.setText(string) and textView.text = $string

前端 未结 5 1723
情歌与酒
情歌与酒 2021-01-20 03:46

Hi I am making a app with Kotlin and I found that I can both use

textView.setText(str)

and

textView.text =         


        
5条回答
  •  不知归路
    2021-01-20 04:22

    textView.setText(str) and textView.text = $str, does the same job of setting the specified str to TextView. The only difference I can come up with is,

    textView.setText(str) // old Java way of setting Text where method setText(str) was being called.

    textView.text = $str //new Kotlin way of setting Text where instead of a method, a synthetic property is being called.

提交回复
热议问题