Tema: Duda en App
Ver Mensaje Individual
  #6  
Viejo 11/04/13, 15:34:09
Array

[xs_avatar]
feelmusic feelmusic no está en línea
Miembro del foro
· Votos compra/venta: (3)
 
Fecha de registro: jul 2012
Localización: Alicante
Mensajes: 359
Modelo de smartphone: Nexus 4
Tu operador: Movistar
Bueno aqui teneis el codigo para ver donde esta el error, el boton al pulsarlo y estar vacio el editText quiero mostra un mensaje, si en el editText hay un numero mayor de 200 mostrar 60 en un TextView y sino (menor que 200) mostrar la operacion matematica "eb".



public class MainActivity extends Activity implements OnClickListener {

EditText editText;
Button boton;

double v1, eb;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);


editText = (EditText) findViewById(R.id.editText);
boton = (Button) findViewById(R.id.boton);

boton.setOnClickListener(this);

public void onClick(View v) {
// TODO Auto-generated method stub


v1 = Double.parseDouble(editText.getText().toString());
eb = v1 * 0.10;//operacion matematica


switch(v.getId()){

case R.id.boton: //Boton

if(editText.getText().toString().trim().equals("") ){

Toast mensaje = Toast.makeText(this, "Introducir un número", Toast.LENGTH_SHORT);
mensaje.show();

}else if (v1 > 200){
//si v1 es mayor de 200
textView1.setText(String.valueOf("60"));
//mostrar en el textview1 60

}else{

textView1.setText(String.valueOf(eb));
//sino mostrar en el textView eb, que es una operacion matematica
}
Responder Con Cita