Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PageFragment extends Fragment {
- public static final String ARG_PAGE = "ARG_PAGE";
- private int mPage;
- public static PageFragment newInstance(int page) {
- Bundle args = new Bundle();
- args.putInt(ARG_PAGE, page);
- PageFragment fragment = new PageFragment();
- fragment.setArguments(args);
- return fragment;
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- mPage = getArguments().getInt(ARG_PAGE);
- }
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment, container, false);
- TextView tvTitle = (TextView) view.findViewById(R.id.text);
- String [] text = new String [4];
- text[0] = "hej";
- text[1] = "farve";
- text[2] = "farv";
- text[3] = "fa";
- tvTitle.setText(text[mPage]);
- return view;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement