Im new to android studio and this is my first project. I have created a simple calculator to add 2 numbers theres no error in code but whenever im trying to run the app it always crashes
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.EditText;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
EditText et1,et2;
Button bu1,bu2,bu3,bu4;
double val,val2,result;
TextView v1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
et1=(EditText)findViewById(R.id.editText);
et2=(EditText)findViewById(R.id.editText2);
v1=(TextView)findViewById(R.id.t3);
bu1=findViewById(R.id.b1);
bu2=findViewById(R.id.b2);
bu3=findViewById(R.id.b3);
bu4=findViewById(R.id.b4);
val = Double.parseDouble(et1.getText().toString());
val2 = Double.parseDouble(et2.getText().toString());
bu1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view) {
result=val+val2;
v1.setText(Double.toString(result));
}
});
}