-1

SectionFragment.class

Intent subjectDetail = new Intent(getContext(), GradeFragment.class);
        ListGradeData clickItem = sectionList.get(position);

        subjectDetail.putExtra(EXTRA_SECTION_ID, String.valueOf(clickItem.getSectionId()));
        startActivity(subjectDetail);

GradeFragment.class

String studSectionId = getActivity().getIntent().getExtras().getString(EXTRA_SECTION_ID);
        Toast.makeText(getContext(), studSectionId, Toast.LENGTH_LONG).show();

it doesn't display the studentSectionId. When I run the app it always crashed after I click the button

BCMDKX
  • 11
  • 6

1 Answers1

0

For fragment use FragmentManager to add/replace fragments. and create send data like

MyFragment myFragment = new MyFragment();

Bundle args = new Bundle();
args.putInt("someInt", someInt);
myFragment.setArguments(args);
kuber singh
  • 289
  • 1
  • 5
  • https://stackoverflow.com/questions/5159982/how-do-i-add-a-fragment-to-an-activity-with-a-programmatically-created-content-v – kuber singh Oct 17 '18 at 07:33