text property of the textview class of android

1

I have a question, before to recover or save text in a textview the methods getText and setText were used, now, yesterday I started working with a textview and the getText method did not appear in the list of recommended methods when I put

objectoTextView.

but I have seen that there is a property of the texview called "text", that passing a value does of setText, also it also makes getText when I call it without passing it a value ....

objectoTextView.text="Hola mundo"
var variable=objectoTextView.Text

My question is, are the textText getText and setText methods obsolete and replaced by "text"?

    
asked by zimp 18.04.2018 в 14:51
source

1 answer

1

What happens is that getText() and setText() are typical of java and .text is for kotlin .

You can tell the difference because in java the code would be something like that

TextView objetoTextView;
objetoTextView.getText();

and in kotlin it is

var objetoTextView; //la diferencia es el var
objetoTextView.text //esto funciona como set o get, depende como lo uses

Kotlin is a language that is officially supported by android (like java or c++ ).

What I think should have happened is that you created a new activity and sometimes the option is not visible, but if you scroll down when you create a new activity, it gives you the choice in which language you want it. If when you created your project you chose to support kotlin, the default activities are created in kotlin unless you change it.

    
answered by 18.04.2018 / 16:30
source