Created
March 15, 2016 14:20
-
-
Save AraujoJordan/3c8944fa4056b6d21ffe to your computer and use it in GitHub Desktop.
[Nova Cursos] Aula6 - MainActivity.java
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.os.Bundle; | |
import android.support.v4.app.FragmentTransaction; | |
import android.support.v7.app.AppCompatActivity; | |
import android.widget.FrameLayout; | |
import java.util.ArrayList; | |
/** | |
* Tela principal do programa, chamada por um dos botões da PrimeiraActivity | |
*/ | |
public class MainActivity extends AppCompatActivity { | |
private Partida partida; | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.fragments); | |
//Criando Respostas | |
String[] respostas = new String[5]; | |
respostas[0] = "1"; | |
respostas[1] = "2"; | |
respostas[2] = "3"; | |
respostas[3] = "4"; | |
respostas[4] = "5"; | |
//Criando quiz | |
Quiz quiz1 = new Quiz("Quanto é 1+1:", respostas, 1); | |
ArrayList<Quiz> quizes = new ArrayList<>(); | |
quizes.add(quiz1); | |
//Criando partida | |
partida = new Partida(quizes); | |
partida.setPerguntaAtual(1); | |
partida.setPontuacao(0); | |
partida.setTempo(0); | |
//Criando QuizFragment | |
QuizFragment quizFragment = new QuizFragment(); | |
quizFragment.addValores(1, partida.getPergunta(0)); | |
if (savedInstanceState == null) { | |
FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); | |
ft.replace(frameLayout.getId(), quizFragment).commit(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment