long1eu / SpaceTabLayout

Not actively maintained, but PR are welcomed
1.6k stars 265 forks source link

How to send data from Activity to Fragment? #42

Open Madi99 opened 5 years ago

Madi99 commented 5 years ago

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