android - How to get view from context?

villager picture villager · Oct 29, 2012 · Viewed 98.7k times · Source

I want to get the view or findViewById() from Context? Or from intent?

I'm trying to reach a specific view in my broadcast receiver and the parameter of onReceive are context and intent.

Well, I have a class and within it is my broadcast receiver. Now, I'm trying to separate the broadcast receiver from it, but I need a way so I can still communicate with the views on my class from my separated broadcast receiver class.

Thanks.

Answer

KuzyaTheBrownie picture KuzyaTheBrownie · Sep 5, 2015

For example you can find any textView:

TextView textView = (TextView) ((Activity) context).findViewById(R.id.textView1);