jeudi 8 mars 2018

if then statement not working and crashes

Been trying to get my code to work but it seems to comes crashing. Can anyone help me? Thank you in advance :-)

EditText HbA1c;
TextView result;
Button button;


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

    HbA1c = (EditText) findViewById(R.id.HbA1c);
    button = (Button) findViewById(R.id.button);
    result = (TextView) findViewById(R.id.result);



public void onButtonClick(View view){

    int num = Integer.parseInt(HbA1c.getText().toString());


    if (HbA1c == 6.5) {
        result.setText("DM");
    } else {
        result.setText("not DM");

}

Aucun commentaire:

Enregistrer un commentaire