如何调用布局';android中的非活动视图

如何调用布局';android中的非活动视图,android,android-layout,android-intent,Android,Android Layout,Android Intent,我有一个要求,我必须调用布局的视图(按钮,文本),就像从非活动 For Example: 1.Utils.java->which is core java class 2.calling setContentView(R.layout.loing); 3.Button btnlogin = (Button)findViewById(R.id.btnlogin); 所以,请告诉我如何做这件事。这样做: Button myBtn = (Button)mContext.findView

我有一个要求,我必须调用布局的视图(按钮,文本),就像从非活动

For Example:

 1.Utils.java->which is core java class
 2.calling setContentView(R.layout.loing);
 3.Button btnlogin = (Button)findViewById(R.id.btnlogin);
所以,请告诉我如何做这件事。

这样做:

Button myBtn = (Button)mContext.findViewById(R.id.btnlogin);

你的问题不清楚!使用活动类的上下文,如
context.findviewbyd()你能写一些代码吗?片段到活动的通信?这是错误的,不要这样做。