I want to change a TextView from another, non-activity class. I see the answer here How to update a TextView of an activity from another class in the adapost's post, but I don't know how to properly pass a context to "ClassB".
In Main class, I tried ClassB obj = new ClassB(this);
and ClassB obj = new ClassB(getApplicationContext());
. But every time, TextView txtView = (TextView)findViewById(R.id.text);
returns NullPointerException.
I am sure that I do it aftersetContentView
, I can acheive this textView from Main class.
How to pass the context to make it work?