Advertisement
vergepuppeter

Aemir-MainActivity

Apr 9th, 2020
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.89 KB | None | 0 0
  1. package com.example.testexample;
  2.  
  3. import androidx.appcompat.app.AppCompatActivity;
  4.  
  5. import android.content.Intent;
  6. import android.os.Bundle;
  7. import android.provider.MediaStore;
  8. import android.view.View;
  9. import android.widget.Button;
  10. import android.widget.EditText;
  11. import android.widget.RadioButton;
  12. import android.widget.RadioGroup;
  13. import android.widget.Toast;
  14.  
  15. import javax.xml.transform.Result;
  16.  
  17.  
  18. public class MainActivity extends AppCompatActivity {
  19.     public static final String EXTRA_HINPUT = "com.example.application.example.EXTRA_HINPUT";
  20.     public static final String EXTRA_WINPUT = "com.example.application.example.EXTRA_WINPUT";
  21.     public static final String IS_MALE = "is_male";
  22.     public static final String EXTRA_FEMALE = "com.example.application.example.EXTRA_FEMALE";
  23.  
  24.     @Override
  25.     protected void onCreate(Bundle savedInstanceState) {
  26.         super.onCreate(savedInstanceState);
  27.         setContentView(R.layout.activity_main);
  28.  
  29.         Button calcbtn = (Button) findViewById(R.id.calculatebtn);
  30.         calcbtn.setOnClickListener(new View.OnClickListener() {
  31.             @Override
  32.             public void onClick(View v) {
  33.                 openResultActivity();
  34.             }
  35.         });
  36.     }
  37.  
  38.     public void openResultActivity(){
  39.         EditText Hinput = (EditText) findViewById(R.id.heightinput);
  40.         double heightinput = Double.parseDouble(Hinput.getText().toString());
  41.  
  42.         EditText Winput = (EditText) findViewById(R.id.weightinput);
  43.         double weightinput = Double.parseDouble(Winput.getText().toString());
  44.  
  45.         RadioButton malebtn = (RadioButton)findViewById(R.id.malebtn);
  46.    
  47.         Intent intent = new Intent(this, ResultActivity.class);
  48.         intent.putExtra(EXTRA_HINPUT, heightinput);
  49.         intent.putExtra(EXTRA_WINPUT, weightinput);
  50.         intent.putExtra(IS_MALE, malebtn.isChecked())
  51.         startActivity(intent);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement