I am creating a simple App for a college prep assignment using android studio
I have been able to develop most of the App but I need help with the following function:
- Make sure all fields are entered
if yes (do maths calculation)
if no (do no maths calculation, have a popup returning "missing field")
like this
Toast.makeText(getApplicationContext(), "Missing Value", Toast.LENGTH_SHORT).show();
I was thinking an If/Else statement but I am new to all this and cant seem to get it to work
Heres the all the java code I have showing the maths functions etc
//Inside the OnCreate
//Linking the Variables
Numet0 = (EditText) findViewById(R.id.editText);
Numet1 = (EditText) findViewById(R.id.editText2);
Numet2 = (EditText) findViewById(R.id.editText3);
b = (Button) findViewById(R.id.button);
tv = (TextView) findViewById(R.id.textView2);
//Creating Function On Button 1
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Double Num0 = Double.parseDouble(Numet0.getText().toString());
Double Num1 = Double.parseDouble(Numet1.getText().toString());
Double Num2 = Double.parseDouble(Numet2.getText().toString());
//Result Output
result = ((Num0 - Num1) / Num2);
tv.setText("Your monthly payment = €" + result);
//Popup After Button Press
Toast.makeText(getApplicationContext(), "Result Complete", Toast.LENGTH_SHORT).show();
}
});
Aucun commentaire:
Enregistrer un commentaire