Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context="com.example.administrator.test.MainActivity">
- <EditText
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:hint="First Number"
- android:textSize="20dp"
- android:layout_marginTop="27dp"
- android:id="@+id/n1"
- android:layout_alignParentTop="true"
- android:layout_alignLeft="@+id/plus"
- android:layout_alignStart="@+id/plus"
- android:layout_alignRight="@+id/n2"
- android:layout_alignEnd="@+id/n2" />
- <EditText
- android:layout_width="250dp"
- android:layout_height="wrap_content"
- android:hint="Second Number"
- android:textSize="20dp"
- android:id="@+id/n2"
- android:layout_marginTop="25dp"
- android:layout_below="@+id/n1"
- android:layout_alignLeft="@+id/plus"
- android:layout_alignStart="@+id/plus"
- android:layout_alignRight="@+id/minus"
- android:layout_alignEnd="@+id/minus" />
- <Button
- android:id="@+id/plus"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="33dp"
- android:text="+"
- android:textSize="30dp"
- android:layout_below="@+id/n2"
- android:layout_alignParentLeft="true"
- android:layout_alignParentStart="true"
- android:layout_marginLeft="46dp"
- android:layout_marginStart="46dp" />
- <Button
- android:id="@+id/minus"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/plus"
- android:layout_alignParentEnd="true"
- android:layout_alignParentRight="true"
- android:layout_marginEnd="73dp"
- android:layout_marginRight="73dp"
- android:textSize="30dp"
- android:text="-" />
- <Button
- android:id="@+id/mul"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignEnd="@+id/plus"
- android:layout_alignRight="@+id/plus"
- android:layout_below="@+id/plus"
- android:layout_marginTop="24dp"
- android:textSize="30dp"
- android:text="*" />
- <Button
- android:id="@+id/div"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/minus"
- android:layout_alignStart="@+id/minus"
- android:layout_alignTop="@+id/mul"
- android:textSize="30dp"
- android:text="/" />
- <TextView
- android:id="@+id/ans"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="30dp"
- android:text="Result"
- android:layout_below="@+id/div"
- android:layout_toLeftOf="@+id/div"
- android:layout_toStartOf="@+id/div"
- android:layout_marginTop="75dp" />
- </RelativeLayout>
- package com.example.administrator.test;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.widget.Button;
- import android.widget.EditText;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- public EditText e1;
- public EditText e2;
- public Button b1;
- public Button b2;
- public Button b3;
- public Button b4;
- public TextView res;
- public double result;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- e1 = (EditText)findViewById(R.id.n1);
- e2 = (EditText)findViewById(R.id.n2);
- b1 = (Button)findViewById(R.id.plus);
- b2 = (Button)findViewById(R.id.minus);
- b3 = (Button)findViewById(R.id.mul);
- b4 = (Button)findViewById(R.id.div);
- res =(TextView)findViewById(R.id.ans);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement