Back to project page BNR-Quiz.
The source code is released under:
MIT License
If you think the Android project BNR-Quiz 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 net.plastboks.bnr_quiz; //from ww w . j a v a 2s. c o m import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; import android.widget.TextView; public class QuizAnswer extends Activity { private boolean answer; private TextView answerTextView; private Button nextButton; public static final String EXTRA_ANSWER = "net.plastboks.bnr_quiz.answer_bool"; private void setActivityBackgroundColor(int color) { View view = this.getWindow().getDecorView(); view.setBackgroundColor(color); } private void parseAnswer() { if (this.answer) { this.answerTextView.setText(R.string.correct_toast); this.setActivityBackgroundColor(0xf00ff000); } else { this.answerTextView.setText(R.string.incorrect_toast); this.setActivityBackgroundColor(0xfff00000); } } @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_quiz_answer); this.answer = getIntent().getBooleanExtra(EXTRA_ANSWER, false); this.answerTextView = (TextView)findViewById(R.id.answer_text_view); this.parseAnswer(); this.nextButton = (Button)findViewById(R.id.next_button); this.nextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { finish(); } }); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.quiz_answer, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); } }