Last active
April 2, 2016 03:29
-
-
Save AraujoJordan/b7fa7cb40dbe2b95ae604fd4f679199f to your computer and use it in GitHub Desktop.
[Nova Cursos] Aula6 QuizPagerAdapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package araujo.jordan.novaquiz; | |
import android.support.v4.app.FragmentManager; | |
import android.support.v4.app.FragmentPagerAdapter; | |
import java.util.ArrayList; | |
/** | |
* Created by Jordan on 02/04/2016. | |
*/ | |
public class QuizPagerAdapter extends FragmentPagerAdapter { | |
private Partida partida; | |
private ArrayList<QuizFragment> quizFragments; | |
public QuizPagerAdapter(FragmentManager fragmentManager, Partida partida) { | |
super(fragmentManager); | |
this.partida = partida; | |
quizFragments = new ArrayList<>(); | |
} | |
@Override | |
public android.support.v4.app.Fragment getItem(int position) { | |
try { | |
return quizFragments.get(position); | |
} | |
catch (IndexOutOfBoundsException notFound) { | |
Quiz quiz = partida.getPergunta(position); | |
QuizFragment quizFrag = new QuizFragment(); | |
quizFrag.addValores(position, quiz); | |
quizFragments.add(quizFrag); | |
return quizFrag; | |
} | |
} | |
@Override | |
public int getCount() { | |
return partida.getQtdPerguntas(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment