Android Open Source - InfiniteViewPager Colour Fragment






From Project

Back to project page InfiniteViewPager.

License

The source code is released under:

Copyright (c) 2012 Antony Tran Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Softwa...

If you think the Android project InfiniteViewPager listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.antonyt.infiniteviewpager;
//w ww. j a  v a2  s  . c  o  m
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * Example Fragment class that shows an identifier inside a TextView.
 */
public class ColourFragment extends Fragment {

    private int identifier;
    private int colour;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bundle args = getArguments();
        colour = args.getInt("colour");
        identifier = args.getInt("identifier");
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        TextView v = new TextView(getActivity());
        v.setGravity(Gravity.CENTER);
        v.setTextSize(40);
        v.setTextColor(Color.BLACK);
        v.setBackgroundColor(colour);
        v.setText("Fragment ID: " + identifier);
        return v;
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putBoolean("dummy", true);
    }
}




Java Source Code List

com.antonyt.infiniteviewpager.ColourFragment.java
com.antonyt.infiniteviewpager.InfinitePagerAdapter.java
com.antonyt.infiniteviewpager.InfiniteViewPager2Activity.java
com.antonyt.infiniteviewpager.InfiniteViewPagerActivity.java
com.antonyt.infiniteviewpager.InfiniteViewPager.java
com.antonyt.infiniteviewpager.MinFragmentPagerAdapter.java