Skip to content

Instantly share code, notes, and snippets.

@appcoreopc
Created March 29, 2016 03:40
Show Gist options
  • Save appcoreopc/7d2ec7abd582afdf3b0e to your computer and use it in GitHub Desktop.
Save appcoreopc/7d2ec7abd582afdf3b0e to your computer and use it in GitHub Desktop.
public static class PlaceholderFragment extends Fragment {
/**
* The fragment argument representing the section number for this
* fragment.
*/
private static final String ARG_SECTION_NUMBER = "section_number";
/**
* Returns a new instance of this fragment for the given section
* number.
*/
public static PlaceholderFragment newInstance(int sectionNumber) {
PlaceholderFragment fragment = new PlaceholderFragment();
Bundle args = new Bundle();
args.putInt(ARG_SECTION_NUMBER, sectionNumber);
fragment.setArguments(args);
return fragment;
}
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragmentviewsimple, container, false);
TextView textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText(getString(R.string.section_format, getArguments().getInt(ARG_SECTION_NUMBER)));
return rootView;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment