【发布时间】:2016-08-15 22:34:22
【问题描述】:
我想从 Fragment_A 更改 Fragment_B 的文本。我怎样才能做到这一点?
类似的东西。
片段_A
ola = (TextView) v.findViewById(R.id.textView12);
ola2 = (TextView) (FRAGMENT_B).findViewById(R.id.textView2);
AsyncTask(ola,ola2).execute //this should set text on Fragment_A and Fragment_B
片段 A:
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_second,container,false);
ola = (TextView) v.findViewById(R.id.textView12);
Asynctask(ola).execute
return v;
}
片段 B:
public class Fragmento_B extends android.support.v4.app.Fragment{
public TextView ola2;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_third,container,false);
ola2 = (TextView) v.findViewById(R.id.textView2);
Asynctask(ola2).execute
return v;
}
}
【问题讨论】:
-
使用参数启动片段 B,然后在片段 B 中获取参数,然后从参数中获取您的值,然后从您的值中获取 setText。
标签: java android android-fragments android-asynctask settext