Answers for "pass data from activity to fragment android"

0

pass data from activity to fragment android

Bundle bundle = new Bundle();
bundle.putString("edttext", "From Activity");
// set Fragmentclass Arguments
Fragmentclass fragobj = new Fragmentclass();
fragobj.setArguments(bundle);

And inside fragment:

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    String strtext = getArguments().getString("edttext");    
    return inflater.inflate(R.layout.fragment, container, false);
}
Posted by: Guest on January-22-2021

Code answers related to "pass data from activity to fragment android"

Browse Popular Code Answers by Language