How To Pass Data From One Fragment To Another Fragment?
Answers (1)
Add AnswerYou can do something like below,
String cid=id.getText().toString(); Fragment fr=new friendfragment(); FragmentManager fm=getFragmentManager(); android.app.FragmentTransaction ft=fm.beginTransaction(); Bundle args = new Bundle(); args.putString("CID", cid); fr.setArguments(args); ft.replace(R.id.content_frame, fr); ft.commit();
To receive the data do the following,
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { String strtext = getArguments().getString("CID"); return inflater.inflate(R.layout.fragment, container, false); }