我想通过单击fragment2中的按钮来更改fragment1中文本视图中的文本,我设法通过将文本视图声明为static
,以便我可以通过更改文本Fragment1.textv.setText("hi");
,这是好的,什么是最好的方式来做到这一点。片段访问控件来自同一活动中的另一个片段
static textv ;
@Override
public View onCreateView( LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final View v = inflater.inflate(R.layout.fragment_frag_beam_rec, container, false);
textv= (TextView)v.findViewById(R.id.textview);
return v;
}