Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.testexample;
- import androidx.appcompat.app.AppCompatActivity;
- import androidx.constraintlayout.widget.ConstraintLayout;
- import android.annotation.SuppressLint;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.RadioButton;
- import android.widget.TextView;
- import android.widget.Toast;
- import org.w3c.dom.Text;
- import javax.xml.transform.Result;
- public class ResultActivity extends AppCompatActivity {
- @SuppressLint("SetTextI18n")
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_result);
- ConstraintLayout conlay;
- TextView textView1 = (TextView) findViewById(R.id.ResultTxt);
- conlay = findViewById(R.id.constraintLayout);
- Intent intent = getIntent();
- double Hinput = intent.getDoubleExtra(MainActivity.EXTRA_HINPUT, 0.0);
- double Winput = intent.getDoubleExtra(MainActivity.EXTRA_WINPUT, 0.0);
- boolean is_male = intent.getBooleanExtra(MainActivity.IS_MALE, true);
- TextView gendertxt = (TextView) findViewById(R.id.TxtGender);
- double result = (Winput / (Hinput * Hinput)) * 10000;
- if(is_male) {
- if (result <= 18.5) {
- conlay.setBackgroundResource(R.drawable.underresult);
- } else if (result >= 18.6 && result <= 24.9) {
- conlay.setBackgroundResource(R.drawable.normalresult);
- } else if (result >= 25.0 && result <= 29.9) {
- conlay.setBackgroundResource(R.drawable.overresult);
- } else if (result >= 30 && result <= 39.9) {
- conlay.setBackgroundResource(R.drawable.obesresult);
- } else if (result >= 40.0) {
- conlay.setBackgroundResource(R.drawable.dresult);
- }
- gendertxt.setText("Male");
- textView1.setText(String.valueOf(result));
- }
- else{
- if (result <= 18.5) {
- conlay.setBackgroundResource(R.drawable.underresult);
- } else if (result >= 18.6 && result <= 24.9) {
- conlay.setBackgroundResource(R.drawable.normalresult);
- } else if (result >= 25.0 && result <= 29.9) {
- conlay.setBackgroundResource(R.drawable.overresult);
- } else if (result >= 30 && result <= 39.9) {
- conlay.setBackgroundResource(R.drawable.obesresult);
- } else if (result >= 40.0) {
- conlay.setBackgroundResource(R.drawable.dresult);
- }
- gendertxt.setText("Female");
- textView1.setText(String.valueOf(result));
- }
- //Sharing Codes Below//
- Button bt;
- bt = (Button) findViewById(R.id.sharebtn);
- bt.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- Intent myIntent = new Intent(Intent.ACTION_SEND);
- myIntent.setType("text/plain");
- String shareBody = "Your body here";
- String shareSub = "Your subject here";
- myIntent.putExtra(Intent.EXTRA_SUBJECT, shareSub);
- myIntent.putExtra(Intent.EXTRA_TEXT, shareBody);
- startActivity(Intent.createChooser(myIntent, "Share using"));
- }
- });
- //Sharing codes End here//
- //Open BMI TABLE is below//
- Button tblbtn;
- tblbtn = (Button) findViewById(R.id.BmiTblBtn);
- tblbtn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(ResultActivity.this, BmiTableActivity.class));
- }
- });
- //Open BMI TABLE Codes End here//
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement