Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.testexample;
- import androidx.appcompat.app.AppCompatActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.provider.MediaStore;
- import android.view.View;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.RadioButton;
- import android.widget.RadioGroup;
- import android.widget.Toast;
- import javax.xml.transform.Result;
- public class MainActivity extends AppCompatActivity {
- public static final String EXTRA_HINPUT = "com.example.application.example.EXTRA_HINPUT";
- public static final String EXTRA_WINPUT = "com.example.application.example.EXTRA_WINPUT";
- public static final String IS_MALE = "is_male";
- public static final String EXTRA_FEMALE = "com.example.application.example.EXTRA_FEMALE";
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- Button calcbtn = (Button) findViewById(R.id.calculatebtn);
- calcbtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- openResultActivity();
- }
- });
- }
- public void openResultActivity(){
- EditText Hinput = (EditText) findViewById(R.id.heightinput);
- double heightinput = Double.parseDouble(Hinput.getText().toString());
- EditText Winput = (EditText) findViewById(R.id.weightinput);
- double weightinput = Double.parseDouble(Winput.getText().toString());
- RadioButton malebtn = (RadioButton)findViewById(R.id.malebtn);
- Intent intent = new Intent(this, ResultActivity.class);
- intent.putExtra(EXTRA_HINPUT, heightinput);
- intent.putExtra(EXTRA_WINPUT, weightinput);
- intent.putExtra(IS_MALE, malebtn.isChecked())
- startActivity(intent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement