1

I am trying to pass the object or the arrayList from this fragment to another. I was using the Intent method but I had the same problem which I do not know what parameter should I put in bundle.putParcelable() method.

BlankFragment1 sendData = new BlankFragment1();         
final Series s = new Series(itemName.getText().toString(),            
Integer.parseInt(itemYear.getText().toString())                 
,Integer.parseInt(itemNumberofSeas.getText().toString()),     
dropDown.getSelectedItem().toString());          
Bundle bundle = new Bundle();         
bundle.putParcelable(s);         
sendData.setArguments(bundle);

1 Answer 1

2

Use setArguments to add the data same as putextra in activity.

Bundle bundle = new Bundle();
bundle.putString("latitude", latitude);
bundles.putSerializable("KEY_ARRAYLIST", DIVID);
bundle.putString("longitude", longitude);
bundle.putString("board_id", board_id);
MapFragment mapFragment = new MapFragment();
mapFragment.setArguments(bundle);

And to get data use getArguments same as getExtra in Activity

String latitude =  getArguments().getString("latitude")
 Arraylist obj=    getArguments().getSerializable("KEY_ARRAYLIST");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.