Advertisement
outattacker

Result2

Feb 15th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.61 KB | None | 0 0
  1. package id.luwakdev.sportszusammen;
  2.  
  3. /**
  4.  * Created by OutAttacker on 2/15/2016.
  5.  */
  6. import android.annotation.SuppressLint;
  7. import android.app.AlertDialog;
  8. import android.content.DialogInterface;
  9. import android.content.Intent;
  10. import android.os.Bundle;
  11. import android.support.v7.widget.Toolbar;
  12. import android.view.View;
  13. import android.view.View.OnClickListener;
  14. import android.widget.ImageView;
  15. import android.widget.TextView;
  16.  
  17. public class Result2 extends Songs {
  18.  
  19.     public int correct1;
  20.     public TextView t1,marks,result;
  21.     public ImageView img;
  22.     Toolbar toolbar;
  23.  
  24.     @SuppressLint("NewApi")
  25.     @Override
  26.     protected void onCreate(Bundle savedInstanceState) {
  27.         super.onCreate(savedInstanceState);
  28.         setContentView(R.layout.result);
  29.  
  30.         result = (TextView)findViewById(R.id.text1);
  31.         marks = (TextView) findViewById(R.id.text2);
  32.         t1= (TextView) findViewById(R.id.text3);;
  33.         img = (ImageView) findViewById(R.id.imageView1) ;
  34.  
  35.         Bundle b=this.getIntent().getExtras();
  36.         // String[] array=b.getStringArray("mes");
  37.         String recive = getIntent().getStringExtra("string");
  38.  
  39.  
  40.         int point = Integer.parseInt(recive);
  41.         //t1.setText(recive);
  42.         marks.setText(recive+" "+"Out Of 15");
  43.         //result.setText(rec.toString());
  44.         if(point == 15 ){
  45.             img.setBackgroundResource(R.drawable.excelent);
  46.             t1.setText("Excellent");}
  47.         if(point > 10 && point <= 14){
  48.             img.setBackgroundResource(R.drawable.good);
  49.             t1.setText("Good");}
  50.         if(point > 5 && point <= 9 ){
  51.             img.setBackgroundResource(R.drawable.average);
  52.             t1.setText("Average");}
  53.         if(point <= 5 ){
  54.             t1.setText("Poor");
  55.             img.setBackgroundResource(R.drawable.poor);
  56.         }
  57.  
  58.         toolbar = (Toolbar) findViewById(R.id.tool_bar);
  59.         setSupportActionBar(toolbar);
  60.         getSupportActionBar().setTitle("Quiz Result");
  61.  
  62.         int[] ques={R.drawable.poor,R.drawable.average,R.drawable.good,R.drawable.excelent};
  63.  
  64.         ///////////////////////////////////////////////////////////
  65.         final View Button = findViewById(R.id.home);
  66.         Button.setOnClickListener(new OnClickListener(){
  67.             @Override
  68.             public void onClick(View view) {
  69.  
  70.                 Intent intent = new Intent(Result2.this,MainActivity.class);
  71.                 startActivity(intent);
  72.                 finish();
  73.             }
  74.         });
  75.  
  76.     }
  77.  
  78.     @Override
  79.     public void onBackPressed() {
  80.         AlertDialog.Builder builder = new AlertDialog.Builder(Result2.this);
  81.         builder.setMessage("Do you really want to exit?.").setCancelable(
  82.                 false).setPositiveButton("Quit",
  83.                 new DialogInterface.OnClickListener() {
  84.                     public void onClick(DialogInterface dialog, int id) {
  85.                         Result2.this.finish();
  86.                         Intent intent = new Intent(Result2.this,MainActivity.class);
  87.                         startActivity(intent);
  88.  
  89.                     }
  90.                 }).setNegativeButton("Cancel",
  91.                 new DialogInterface.OnClickListener() {
  92.                     public void onClick(DialogInterface dialog, int id) {
  93.  
  94.                     }
  95.                 });
  96.         AlertDialog alert = builder.create();
  97.         alert.show();
  98.  
  99.     }
  100.     public boolean onCreateOptionsLayout(View view) {
  101.         // Inflate the menu; this adds items to the action bar if it is present.
  102.         getLayoutInflater().inflate(R.layout.activity_main, null);
  103.         return true;
  104.     }
  105.  
  106.  
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement