Back to project page ScienceQuiz.
The source code is released under:
GNU General Public License
If you think the Android project ScienceQuiz listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.finger.sciencequiz; // w w w .j a va2 s.com import com.finger.sciencequiz.R; import android.os.Bundle; import android.os.Handler; import android.support.v4.app.Fragment; import android.support.v4.view.ViewPager; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; /** * A dummy fragment representing a section of the app, but that simply * displays dummy text. */ public class StartHomeFragment extends Fragment { public StartHomeFragment () { super (); h = new Handler (); d = new Diashow (this); } protected ViewPager gallery; protected int galPos; protected Handler h; protected Runnable d; protected final int DIA_DELAY = 7000; @Override public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate ( R.layout.fragment_main_start, container, false); gallery = (ViewPager) rootView.findViewById (R.id.gallery_view_pager); ImageAdapter adapter = new ImageAdapter (inflater, rootView.getContext ()); gallery.setAdapter (adapter); return rootView; } @Override public void onResume () { super.onResume (); h.postDelayed (d, DIA_DELAY); } @Override public void onPause () { super.onPause (); h.removeCallbacks (d); } public void next () { galPos = (galPos + 1) % 3; gallery.setCurrentItem (galPos); } class Diashow implements Runnable { public Diashow (StartHomeFragment f) { this.f = f; } protected StartHomeFragment f; @Override public void run () { f.next (); h.postDelayed (this, f.DIA_DELAY); } } }