Android example of updating textview

To find Text View we will use find View By Id() method (it allows to find any type of View, but now we know only Text View…).

First we have to create a variable based on Text View class.

We finished previous lesson displaying I’m the best from file.

But imagine that we would like to change this text to I love you.

Instead IDs are added (that’s why we use ) or generated when the app is started.

First we have to create a variable that would store original text from layout file. The same what we did in previous step we could do just by one method.First add a new definition to file: There is one more option.As an argument of set Text() we could also use a String variable (so the variable storing a text).First define a variable (for instance named new Text), then assign some text to it and finally set this text to Text View.Instead of assigning a text we could again refer to string resources.This line displays on device screen layout resource – in this case activity_file.

You must have an account to comment. Please register or login here!