• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Button doesn't work

RobinF

Lurker
May 24, 2013
1
0
Hi guys,

i'm making an app and when ever i press the button the app crashes

The button calls the Calculate function
And all the EditText fields are input fields

[HIGH]
package org.flikkema.robin.demeneerpalsberekeningsappvoorandroid;
//COPYRIGHT ROBINFLIKKEMA @ FLIKKEMA.ORG
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.widget.EditText;

public class MainActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Bind the EditText views

EindCijfer = (EditText)findViewById(R.id.EditText10);
Cijfer1 = (EditText)findViewById(R.id.EditText01);
Cijfer2 = (EditText)findViewById(R.id.editText1);
Cijfer3 = (EditText)findViewById(R.id.EditText02);
Cijfer4 = (EditText)findViewById(R.id.EditText04);
Cijfer5 = (EditText)findViewById(R.id.EditText03);
Cijfer6 = (EditText)findViewById(R.id.EditText11);
Weging1 = (EditText)findViewById(R.id.EditText08);
Weging2 = (EditText)findViewById(R.id.EditText09);
Weging3 = (EditText)findViewById(R.id.EditText05);
Weging4 = (EditText)findViewById(R.id.EditText06);
Weging5 = (EditText)findViewById(R.id.EditText07);
Weging6 = (EditText)findViewById(R.id.EditText12);


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

EditText EindCijfer;
EditText Cijfer1;
EditText Weging1;
EditText Cijfer2;
EditText Weging2;
EditText Cijfer3;
EditText Weging3;
EditText Cijfer4;
EditText Weging4;
EditText Cijfer5;
EditText Weging5;
EditText Cijfer6;
EditText Weging6;



public void Calculate(View v){
// Wanneer je op de button drukt
Bereken();
}

public void Bereken() {
Double value1 = Double.parseDouble(Cijfer1.getText().toString());
Double value2 = Double.parseDouble(Cijfer2.getText().toString());
Double value3 = Double.parseDouble(Cijfer3.getText().toString());
Double value4 = Double.parseDouble(Cijfer4.getText().toString());
Double value5 = Double.parseDouble(Cijfer5.getText().toString());
Double value6 = Double.parseDouble(Cijfer6.getText().toString());
Double value7 = Double.parseDouble(Weging1.getText().toString());
Double value8 = Double.parseDouble(Weging2.getText().toString());
Double value9 = Double.parseDouble(Weging3.getText().toString());
Double value10 = Double.parseDouble(Weging4.getText().toString());
Double value11 = Double.parseDouble(Weging5.getText().toString());
Double value12 = Double.parseDouble(Weging6.getText().toString());
// Bereken
if (value6 == null){
if (value5 == null){
if (value4 == null){
if (value3 == null){
if (value2 == null){
if (value1 == null){
// Do nothing
}
// Set output to Cijfer 1
Double calculatedValue = (value1);
// Output
EindCijfer.setText(calculatedValue.toString());
}
// Calculate Average over Cijfer 1 and 2
Double calculatedValue = ((value1*value7)+(value2*value8))/(value7+value8);
// Output
EindCijfer.setText(calculatedValue.toString());
}
// Calculate Average over Cijfer 1 and 2 and 3
Double calculatedValue = ((value1*value7)+(value2*value8)+(value3*value9))/(value7+value8+value9);
// Output
EindCijfer.setText(calculatedValue.toString());
}
// Calculate Average over Cijfer 1 and 2 and 3 and 4
Double calculatedValue = ((value1*value7)+(value2*value8)+(value3*value9)+(value4*value10))/(value7+value8+value9+value10);
// Output
EindCijfer.setText(calculatedValue.toString());
}
// Calculate Average over Cijfer 1 and 2 and 3 and 4 and 5
Double calculatedValue = ((value1*value7)+(value2*value8)+(value3*value9)+(value4*value10)+(value5*value11))/(value7+value8+value9+value10+value11);
// Output
EindCijfer.setText(calculatedValue.toString());
}
// Calculate Average over Cijfer 1 and 2 and 3 and 4 and 5 and 6
Double calculatedValue = ((value1*value7)+(value2*value8)+(value3*value9)+(value4*value10)+(value5*value11)+(value6*value12))/(value7+value8+value9+value10+value11+value12);
// Output
EindCijfer.setText(calculatedValue.toString());
}

}

[/HIGH]

Can Someone help me out?
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones