BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight,

Slides:



Advertisements
Similar presentations
All About Android Introduction to Android 1. Creating a New App “These aren’t the droids we’re looking for.” Obi-wan Kenobi 1. Bring up Eclipse. 2. Click.
Advertisements

Application Fundamentals. See: developer.android.com/guide/developing/building/index.html.
Who Am I And Why Am I Here I’m professor Stephen Fickas in CIS – you can call me Steve. I have a research group that works with mobile devices (since 1995!)
User Interface Android Applications. Activities An activity presents a visual user interface. Each activity is given a default window to draw in. The.
Cosc 4730 Android TabActivity and ListView. TabActivity A TabActivity allows for multiple “tabs”. – Each Tab is it’s own activity and the “root” activity.
Android Development (Basics)
@2011 Mihail L. Sichitiu1 Android Introduction Hello World.
Android Application Development Tutorial. Topics Lecture 5 Overview Overview of Networking Programming Tutorial 2: Downloading from the Internet.
Introduction to Android Programming Content Basic environmental structure Building a simple app Debugging.
Package org.androidtown.database.query; import android.app.Activity; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase;
1 Announcements Homework #2 due Feb 7 at 1:30pm Submit the entire Eclipse project in Blackboard Please fill out the when2meets when your Project Manager.
1/29/ Android Programming: FrameLayout By Dr. Ramji M. Makwana Professor and Head, Computer Engineering Department A.D. Patel.
Android Dialog Boxes AlertDialog - Toast
Android - Broadcast Receivers
Import import android.graphics.Bitmap; import android.widget.ImageView;
1 Introducing Activity and Intent. 2 Memory LinearLayout, weight=2 LinearLayout, weight=1 TextView ListView.
ANDROID – DRAWING IMAGES – SIMPLE EXAMPLE IN INTERFACE AND EVENT HANDLING L. Grewe.
Android Boot Camp Demo Application – Part 1. Development Environment Set Up Download and install Java Development Kit (JDK) Download and unzip Android.
Android Using Menus Notes are based on: The Busy Coder's Guide to Android Development by Mark L. Murphy Copyright © CommonsWare, LLC. ISBN:
ANDROID – A FIRST PROGRAM L. Grewe Using AndroidStudio –basic Android  Lets do a “Hello World Project”  Start up AndroidStudio (assume you have installed.
HW#9 Clues CSCI 571 Fall, HW#9 Prototype
Copyright© Jeffrey Jongko, Ateneo de Manila University Deconstructing HelloWorld.
Android and s Ken Nguyen Clayton state University 2012.
Android 基本 I/O. 基本 I/O 介面元件 在此節中主要介紹常見的 I/O 使用者介 面元件 – Button, TextView, 以及 EditText , 學習者可以學會: – Android 的視窗表單設計 res/layout/main.xml – Android SDK –
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
CMPE419 Mobile Application Development Asst.Prof.Dr.Ahmet Ünveren SPRING Computer Engineering Department Asst.Prof.Dr.Ahmet Ünveren
Lab7 – Appendix.
Introduction to android
Lab7 – Advanced.
Android Programming - Features
Lecture 3 Zablon Ochomo Android Layouts Lecture 3 Zablon Ochomo
Android Introduction Hello World
Android N Amanquah.
GUI Programming Fundamentals
Android – Event Handling
Android Introduction Hello World.
S.RENUKADEVI/AP/SCD/ANDROID - Notifications
Android Widgets 1 7 August 2018
Android Introduction Hello Views Part 1.
ITEC535 – Mobile Programming
Android – Read/Write to External Storage
Android 10: The Silly String App
Android 10: The Silly String App
Android App Computations
Picasso Revisted.
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CS323 Android Model-View-Controller Architecture
Android Programming Lecture 6
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CMPE419 Mobile Application Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
CIS 470 Mobile App Development
Adding Components to Activity
CMPE419 Mobile Application Development
BLP 4216 MOBİL UYGULAMA GELİŞTİRME-2
User Interface Screen Elements
CMPE419 Mobile Application Development
User Interface Screen Elements
Lasalle-App Tecnología Móvil.
Android Sensor Programming
Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
CIS 694/EEC 693 Android Sensor Programming
Android Sensor Programming
Presentation transcript:

BMI Android Application will take weight and height from the users to calculate Body Mass Index (BMI) with the information, whether user is underweight, normal or overweight. The app icon will start showing up on your menus section. Run the app and follow the steps as given above. This app will tell you that your BMI is normal or you are underweight or overweight. If you don’t enter any value in height and weight columns it will automatically ask to input it. CASE STUDY

Designing First Android Application (BMI Calculator) For making an application we have to design the content using XML that how will it look at application screen. For designing BMI application: Choose any layout on which application is to be designed (Eg: Linear Layout etc.). Get any desired background; copy paste your desired image in Drawable folder then access it from Text views – To display content like BMI Calculator, weight, height and final result. Edit texts – To get the input values for height and weight. Button – To get the result when it’s clicked.

It is used for designing front view of application. Activity_main.xml XML file provide basic environment or design for your android application. By using different views and layouts you can design application of your choice. For this you just have to know the basic XML Tags for designing interface. XML coding of this application

<LinearLayout xmlns:android=" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fadingEdge="horizontal" android:orientation="vertical" >

<TextView android:layout_width="124dp" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingLeft="15dp" android:paddingTop="40dp" android:shadowDx="4" android:shadowDy="4" android:text="BMI" android:textAppearance="?android:attr/textAppearanceLarge" android:textSize="50sp" android:typeface="serif" />

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:text="Calculator" android:textSize="20dp" android:textStyle="bold" />

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingTop="30dp" android:text="WEIGHT (KG)" android:textAppearance="?android:attr/textAppearanceMedium " android:textStyle="bold|italic" android:typeface="serif" />

<EditText android:layout_width="96dp" android:layout_height="wrap_content" android:layout_gravity="center" android:hint="IN KGs" android:ems="10" android:fadingEdgeLength="10dp" android:inputType="numberDecimal" android:textAlignment="center" >

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingTop="30dp" android:text="HEIGHT (CM)" android:textAppearance="?android:attr/textAppear anceMedium" android:textStyle="bold|italic" android:typeface="serif" />

<EditText android:layout_width="96dp" android:layout_height="wrap_content" android:layout_gravity="center" android:hint="IN CMs" android:ems="10" android:inputType="numberDecimal" >

<Button android:layout_width="158dp" android:layout_height="51dp" android:layout_gravity="center" android:layout_marginTop="20dp" android:fadingEdge="vertical" android:longClickable="true" android:text="Calculate" android:visibility="visible" />

<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:paddingTop="20dp" android:text="" android:textSize="20dp" android:textStyle="bold"

Java codes While we create our project at that time an XML file and a java file is created separately. MainActivity.java is the file where we do coding for java to implement logic and functionality in the app. MainActivity.java After you have designed your application using XML coding, you have to use the JAVA code so that when ‘Calculate’ button is clicked, it calculates the value and show you the desired result. This is done after designing the user interface. Java file can be found in your project in src folder.

//Import necessary package and file package M2-SEM; import android.os.Bundle; import android.app.Activity; import android.text.TextUtils; import android.view.Menu; import android.view.View; import android.widget.EditText; import android.widget.TextView;

//Main activity class start here public class MainActivity extends Activity { //Define protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main);

// Get the references to the widgets final EditText e1 = (EditText) findViewById(R.id.et1); final EditText e2 = (EditText) findViewById(R.id.et2); final TextView tv4 = (TextView) findViewById(R.id.tv4); findViewById(R.id.ib1).setOnClickListener(new View.OnClickListener() {

// Logic for validation, input can't be public void onClick(View v) { String str1 = e1.getText().toString(); String str2 = e2.getText().toString(); if(TextUtils.isEmpty(str1)){ e1.setError("Please enter your weight"); e1.requestFocus(); return; } if(TextUtils.isEmpty(str2)){ e2.setError("Please enter your height"); e2.requestFocus(); return; }

//Get the user values from the widget reference float weight = Float.parseFloat(str1); float height = Float.parseFloat(str2)/100; //Calculate BMI value float bmiValue = calculateBMI(weight, height); //Define the meaning of the bmi value String bmiInterpretation = interpretBMI(bmiValue); tv4.setText(String.valueOf(bmiValue + "-" + bmiInterpretation)); } //end of onClick }) ; // end of setOnClickListener } // end of onCreate

//Calculate BMI private float calculateBMI (float weight, float height) { return (float) (weight / (height * height)); } // Interpret what BMI means private String interpretBMI(float bmiValue) { if (bmiValue < 16) { return "Severely underweight"; } else if (bmiValue < 18.5) { return "Underweight"; } else if (bmiValue < 25) { return "Normal"; } else if (bmiValue < 30) { return "Overweight"; } else { return "Obese"; } } // end of interpretBMI } // end of MainActivity