SpaceTabLayout icon indicating copy to clipboard operation
SpaceTabLayout copied to clipboard

How to send data from Activity to Fragment?

Open Madi99 opened this issue 5 years ago • 0 comments

MyActivity onCreate

Bundle bundle=new Bundle();
        bundle.putString("name", "From Activity");
        bundle.putInt("id", 4);
        FragmentA fragobjA = new FragmentA();
        fragobjA.setArguments(bundle);

and this FragmentA

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View rootView = inflater.inflate(R.layout.fragment_a, container, false);
        Bundle bundle = this.getArguments();
        if (bundle != null) {
            nomor = bundle.getInt("id", 0);
            info= bundle.getString("name");

        }; 
        return rootView;
       
    } .....

error nomor and id value : null

Madi99 avatar Aug 13 '19 16:08 Madi99