How to pass String[]
from MainActivity
example.add(new Fragment1(new String[]{"answer 1", "answer 2", "answer 3"}));
example.add(new Fragment1(new String[]{"answer 4", "answer 5", "answer 6"}));
to this Fragment
and make it work dynamically (on swipe)
public class Fragment1 extends Fragment {
String stringValue;
int imagesResId;
TextView text;
String[] rbData;
public Fragment1() {
}
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) {
View view = inflater.inflate(R.layout.fragment1, container, false);
text = view.findViewById(R.id.textView);
ImageView imageResId = view.findViewById(image);
text.setText(stringValue);
imageResId.setImageResource(imagesResId);
return view;
}
}