Witajcie,
udaje mi się podmieniać tekst po przesunięciu ekranu, jak i zdjęcie. Mam jednak problem jak podmieniać dane ze String[] ("option1" ...itd.) w radioButtonach w metodzie onCreateView. Dane są podmieniane dynamicznie.
public class Fragment1 extends Fragment {
public Fragment1() {
}
String stringValue;
int imagesResId;
TextView text;
String[] rbData;
View answer;
public Fragment1(String str, int imageView , String[] rb) {
this.stringValue = str;
this.imagesResId = imageView;
this.rbData = rb;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Log.i("x","onCreateViewFragment");
View view = inflater.inflate(R.layout.fragment1, container, false);
text = view.findViewById(R.id.textView);
ImageView imageResId = view.findViewById(image);
answer = view.findViewById(radioGroup);
text.setText(stringValue);
imageResId.setImageResource(imagesResId);
//MainActivity
frags = new ArrayList<>();
frags.add(new Fragment1("Text1", R.drawable.nature2, new String[]{"option 1", "option 2", "option 3"}));
frags.add(new Fragment1("Text2",R.drawable.nature4, new String[]{"option 4", "option 5", "option 6"}));