package com.mandeepshergill.tipcalc;

import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {
	EditText costField;
	EditText percField;
	TextView answer;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
        Button btn = (Button) findViewById(R.id.button1);
        btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				EditText costField = (EditText)findViewById(R.id.editText1);
				EditText percField = (EditText)findViewById(R.id.editText2);
				TextView answer = (TextView)findViewById(R.id.textView2);
        		double cost = Double.parseDouble(costField.getText().toString());
        		double percent = Double.parseDouble(percField.getText().toString());
        		double tip = (percent * 0.01) * cost;
        		String display = "" + tip; 
        		answer.setText(display);
			}
        });
    }
}
@@ -116,80 +116,8 @@
 ew;%0A
-import android.view.View.OnClickListener;%0Aimport android.widget.Button;%0A
 impo
@@ -434,139 +434,11 @@
 );%0A%09
-%09%0A        Button btn = (Button) findViewById(R.id.button1);%0A        btn.setOnClickListener(new OnClickListener() %7B%0A%0A%09%09%09@Override%0A%09%09
+%7D%0A%0A
 %09pub
@@ -450,15 +450,12 @@
 oid 
-onClick
+calc
 (Vie
@@ -464,18 +464,16 @@
 arg0) %7B%0A
-%09%09
 %09%09EditTe
@@ -527,18 +527,16 @@
 Text1);%0A
-%09%09
 %09%09EditTe
@@ -590,18 +590,16 @@
 Text2);%0A
-%09%09
 %09%09TextVi
@@ -654,26 +654,24 @@
 2);%0A        
-%09%09
 double cost 
@@ -728,26 +728,24 @@
 ));%0A        
-%09%09
 double perce
@@ -809,18 +809,16 @@
         
-%09%09
 double t
@@ -855,18 +855,16 @@
         
-%09%09
 String d
@@ -891,18 +891,16 @@
         
-%09%09
 answer.s
@@ -921,27 +921,7 @@
 );%0A%09
-%09%09%7D%0A        %7D);%0A    
 %7D%0A%7D

use layout button binding instead of writing out click handler