atultiwari

AnswersActivity.java

Jul 16th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 KB | None | 0 0
  1. //----- AnswersActivity.java -----//
  2.  
  3. package com.atultiwari.medicalquiz;
  4.  
  5. import android.app.Activity;
  6. import android.os.Bundle;
  7. import android.view.KeyEvent;
  8. import android.view.View;
  9. import android.view.View.OnClickListener;
  10. import android.widget.Button;
  11. import android.widget.TextView;
  12.  
  13. /**
  14.  * @author robert.hinds
  15.  *
  16.  */
  17. public class AnswersActivity extends Activity implements OnClickListener {
  18.    
  19.     @Override
  20.     public void onCreate(Bundle savedInstanceState) {
  21.         super.onCreate(savedInstanceState);
  22.         setContentView(R.layout.answers);
  23.         GamePlay currentGame = ((QuizApplication)getApplication()).getCurrentGame();
  24.        
  25.         TextView results = (TextView)findViewById(R.id.answers);
  26.         String answers = Utility.getAnswers(currentGame.getQuestions());
  27.         results.setText(answers);
  28.        
  29.         //handle button actions
  30.         Button finishBtn = (Button) findViewById(R.id.finishBtn);
  31.         finishBtn.setOnClickListener(this);
  32.        
  33.     }
  34.    
  35.  
  36.    
  37.     /* (non-Javadoc)
  38.      * @see android.app.Activity#onKeyDown(int, android.view.KeyEvent)
  39.      *
  40.      * This method is to override the back button on the phone
  41.      * to prevent users from navigating back in to the quiz
  42.      */
  43.     @Override
  44.     public boolean onKeyDown(int keyCode, KeyEvent event)
  45.     {
  46.         switch (keyCode)
  47.         {
  48.         case KeyEvent.KEYCODE_BACK :
  49.             return true;
  50.         }
  51.        
  52.         return super.onKeyDown(keyCode, event);
  53.     }
  54.  
  55.  
  56.     @Override
  57.     public void onClick(View v) {
  58.         switch (v.getId()){
  59.         case R.id.finishBtn :
  60.             finish();
  61.         }
  62.     }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment