uopspop

Untitled

Sep 27th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. package idv.ron.activitiesdemo;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.view.View;
  6. import android.widget.TextView;
  7.  
  8. import java.text.NumberFormat;
  9.  
  10. public class ResultActivity extends AppCompatActivity {
  11.     private TextView tvResult;
  12.  
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState) {
  15.         super.onCreate(savedInstanceState); // ζŽ₯下青 Bundle bundle = super.getIntent().getExtras();
  16.         setContentView(R.layout.result_activity);
  17.         tvResult = (TextView) findViewById(R.id.tvResult);
  18.         showResults();
  19.     }
  20.  
  21.     private void showResults() {
  22.         NumberFormat nf = NumberFormat.getInstance();
  23.         Bundle bundle = super.getIntent().getExtras(); // here!
  24.         int programming = bundle.getInt("programming");
  25.         int dataStructure = bundle.getInt("dataStructure");
  26.         int algorithm = bundle.getInt("algorithm");
  27.         int sum = programming + dataStructure + algorithm;
  28.         double average = sum / 3.0;
  29.         String text = "programming = " + programming +
  30.                 "\ndataStructure = " + dataStructure +
  31.                 "\nalgorithm = " + algorithm +
  32.                 "\nsum = " + sum +
  33.                 "\naverage = " + nf.format(average);
  34.         tvResult.setText(text);
  35.     }
  36.  
  37.     public void onBackClick(View view) {
  38.         finish(); // implicitly call destory() method to end this activity
  39.     }
  40. }
Add Comment
Please, Sign In to add comment