Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
475 views
in Technique[技术] by (71.8m points)

android - How to get view from context?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

For example you can find any textView:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...