Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public class PageFragment extends Fragment {
  2. public static final String ARG_PAGE = "ARG_PAGE";
  3.  
  4. private int mPage;
  5.  
  6. public static PageFragment newInstance(int page) {
  7. Bundle args = new Bundle();
  8. args.putInt(ARG_PAGE, page);
  9. PageFragment fragment = new PageFragment();
  10. fragment.setArguments(args);
  11. return fragment;
  12. }
  13.  
  14. @Override
  15. public void onCreate(Bundle savedInstanceState) {
  16. super.onCreate(savedInstanceState);
  17. mPage = getArguments().getInt(ARG_PAGE);
  18.  
  19. }
  20.  
  21. @Override
  22. public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
  23. View view = inflater.inflate(R.layout.fragment, container, false);
  24. TextView tvTitle = (TextView) view.findViewById(R.id.text);
  25. String [] text = new String [4];
  26. text[0] = "hej";
  27. text[1] = "farve";
  28. text[2] = "farv";
  29. text[3] = "fa";
  30. tvTitle.setText(text[mPage]);
  31. return view;
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement