Fragment_BのテキストをFragment_Aから変更したいとします。これどうやってするの?他のアクティビティ/フラグメントのテキストを設定する方法
このようなものです。
Fragment_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をフェッチします。 –