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);
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){
}
}
}
}