Send data from activity to fragment using Tab Layout with Swipeable Views in Android

前端 未结 2 934
闹比i
闹比i 2021-01-29 05:21

I created a Tab Layout with Swipeable Views using this tutorial. I\'m trying to pass a string from Activity to Fragment. I read about fragment communication and couple other top

2条回答
  •  不知归路
    2021-01-29 06:08

    I do not see that you set your argument to fragment. If you did, but you forgotten to write please inform me...

    Bundle bundle=new Bundle();
    bundle.putString("email", "emasiofnasdbjk");
    EnterExitFragment enterExitFragment = new EnterExitFragment();
    enterExitFragment.setArguments(bundle); // This line is needed...
    android.support.v4.app.FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
    transaction.replace(R.id.pager, enterExitFragment);
    transaction.addToBackStack(null);
    transaction.commit();
    

提交回复
热议问题