ad728

Saturday, January 13, 2018

AIDE Tutorial - 51 Volume Calculator


Watch the Video Below:

MainActivity.java
package com.kcgroup.vc;
import android.app.*;
import android.os.*;
import android.widget.*;
import android.view.View.*;
import android.view.*;

public class MainActivity extends Activity
{ TextView Result;
EditText HeightET,BreadthET,LengthET;
    @Override
    protected void onCreate(Bundle savedInstanceState)    {        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
Button btncal=(Button)findViewById(R.id.maincalbutton);
HeightET=(EditText)findViewById(R.id.mainEditTextheight);
BreadthET=(EditText)findViewById(R.id.mainEditTextbreadth);
LengthET =(EditText)findViewById(R.id.mainEditTextlength);
Result=(TextView)findViewById(R.id.mainTextViewResult);
btncal.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v)
{float heigth,length,breadth,volume;heigth=Float.parseFloat(HeightET.getText().toString());length=Float.parseFloat(LengthET.getText().toString());breadth=Float.parseFloat(BreadthET.getText().toString());
volume=length*breadth*heigth;
Result.setText("Result : "+volume);
// TODO: Implement this method
}});    }}

Main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="Enter Height"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextheight"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Enter Breadth"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextbreadth"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:text="Enter Length"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<EditText
android:inputType="number|numberDecimal"
android:id="@+id/mainEditTextlength"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<Button
android:text="Calculate"
android:id="@+id/maincalbutton"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/mainTextViewResult"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>

Share:

0 comments:

Post a Comment

Total Pageviews

Sponsor

Sponsor

ad300