'I have a tab layout in my activity in android studio(Java). I want to pass a string to the fragments(tab Item). How can I do that, please reply

I have tried this earlier but doesn't seem to work:

In activity

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

In fragment

String strtext = getArguments().getString("edttext");


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source