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.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- import javax.xml.transform.Result;
- public class ResultActivity extends AppCompatActivity {
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_result);
- ConstraintLayout conlay;
- TextView textView1 = (TextView) findViewById(R.id.ResultTxt);
- TextView txtview2 = (TextView) findViewById(R.id.TxtGender);
- Intent intent = getIntent();
- double Hinput = intent.getIntExtra(MainActivity.EXTRA_HINPUT,0);
- double Winput = intent.getIntExtra(MainActivity.EXTRA_WINPUT,0);
- String maletxt = intent.getStringExtra(MainActivity.EXTRA_MALE);
- String femaletxt = intent.getStringExtra(MainActivity.EXTRA_FEMALE);
- String gender;
- double calc = (Winput / (Hinput * Hinput)) * 10000;
- int result = (int) calc;
- conlay = findViewById(R.id.constraintLayout);
- switch(gender){
- case maletxt:
- 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);
- }
- textView1.setText("" + result);
- break;
- case femaletxt:
- txtview2.setText("FEMALE");
- 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);
- }
- textView1.setText("" + result);
- default:
- textView1.setText(""+ 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