Answers for "Passing data from an activity to a fragment"

0

Passing data from an activity to a fragment

Bundle bundle = new Bundle();
 String myMessage = "Stack Overflow is cool!";
 bundle.putString("message", myMessage );
 FragmentClass fragInfo = new FragmentClass();
 fragInfo.setArguments(bundle);
 transaction.replace(R.id.fragment_single, fragInfo);
 transaction.commit();
Posted by: Guest on August-15-2021
0

Passing data from an activity to a fragment

@Override
 public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    String myValue = this.getArguments().getString("message");
    ...
 }
Posted by: Guest on August-15-2021

Code answers related to "Passing data from an activity to a fragment"

Browse Popular Code Answers by Language