Advertisement
nguyenvanquan7826

Untitled

Jul 4th, 2013
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package android.activity;
  2. import android.os.Bundle;
  3. import android.app.Activity;
  4. import android.content.Intent;
  5. import android.view.View;
  6. import android.view.View.OnClickListener;
  7. import android.widget.Button;
  8. import android.widget.EditText;
  9. import android.widget.TextView;
  10.  
  11. public class Activity2 extends Activity
  12. {
  13.     @Override
  14.     protected void onCreate(Bundle savedInstanceState)
  15.     {
  16.         super.onCreate(savedInstanceState);
  17.         setContentView(R.layout.activity_trung_binh_cong);
  18.        
  19.         EditText Ea, Eb, Ec;
  20.         final TextView TB;
  21.         float a,b,c;
  22.         final float tbc;
  23.         Ea = (EditText) findViewById(R.id.a);
  24.         Eb = (EditText) findViewById(R.id.b);
  25.         Ec = (EditText) findViewById(R.id.c);
  26.         TB = (TextView) findViewById(R.id.KQ);
  27.         /*a = Float.parseFloat(Ea.getText().toString());
  28.         b = Float.parseFloat(Eb.getText().toString());
  29.         c = Float.parseFloat(Ec.getText().toString());
  30.         tbc = (a+b+c)/3;*/
  31.         final Button click_KQ = (Button)findViewById(R.id.send);
  32.         final Button click_back = (Button)findViewById(R.id.back);
  33.         click_KQ.setOnClickListener(new OnClickListener()
  34.         {
  35.             @Override
  36.             public void onClick(View v)
  37.             {
  38.                 a = Float.parseFloat(Ea.getText().toString());
  39.                 b = Float.parseFloat(Eb.getText().toString());
  40.                 c = Float.parseFloat(Ec.getText().toString());
  41.                 tbc = (a+b+c)/3;
  42.                 TB.setText(String.valueOf(tbc));
  43.             }
  44.         });
  45.         click_back.setOnClickListener(new OnClickListener()
  46.         {
  47.             @Override
  48.             public void onClick(View v)
  49.             {
  50.                 Intent intent = new Intent(getApplicationContext(), MainActivity.class);
  51.                 startActivity(intent);
  52.             }
  53.         });
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement