Joshua Aragon Joshua Aragon - 3 months ago 9
Java Question

How to update a TextView from another

I am new to android/java programming. I have two class, one is an activity and other normal class. In my activity class contains TextView. Can i update my TextView of one class from a editText(that the user enters) in a another class. I tried with random code, but it fails. Please help I've been looking forever

Answer

You might update the TextView from wherever in the java code by referring to the

findViewById(R.id.some_text_view_name).

Some what like this:

TextView textViewName = (TextView) findViewById(R.id.some_text_view_name);
textViewName.methodName();

Here methodName() refers to the Public methods listed here

Hope it helps. :)

Comments