because I am currently using android studio and basically when I add the EditText, Buttons and Textview in the design I do not get any error but when I add code to the Onclick so that this event is executed in a button I close the app on the phone and I would like to know what the error is, they have told me that it is because of my code that it must have some logical error or so, but in reality, no, my code has no errors and I do not know which other error is
public class divisas1 extends AppCompatActivity implements View.OnClickListener {
private Button casa;
private Button ok;
private Button clean;
private EditText txt;
private TextView dol;
private TextView eu;
private TextView yn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_divisas1);
casa.findViewById(R.id.menu);
ok.findViewById(R.id.aceptar);
clean.findViewById(R.id.borrar);
txt.findViewById(R.id.texto);
dol.findViewById(R.id.dolares);
eu.findViewById(R.id.euros);
yn.findViewById(R.id.yenes);
casa.setOnClickListener(this);
ok.setOnClickListener(this);
clean.setOnClickListener(this);
}
@Override
public void onClick(View view) {
try{
switch (view.getId()){
case R.id.aceptar:
String pl =txt.getText().toString();
double pesos=Double.parseDouble(pl);
double d,y,e;
d=pesos/17;
dol.setText(""+d);
e=pesos/20;
eu.setText(""+e);
y=pesos/0.17;
yn.setText(""+y);
break;
case R.id.borrar:
dol.setText("");
eu.setText("");
yn.setText("");
break;
case R.id.menu:
Intent mmm= new Intent(divisas1.this, MainActivity.class);
startActivity(mmm);
this.finish();
break;
}
}catch (Exception ignored){
}
}
}
Do you find any error in this code?