@panryz ![d3b8450da0.png](//static.4programmers.net/uploads/attachment/d3b8450da0.png)
Kod:
public void Oblicz_BMI(View view) {
double tempWeight;
double tempHeight;
double YourBMI;
String ifEmptyWeight,ifEmptyHeight;
EditText Weight = (EditText) findViewById(R.id.WeightID);
tempWeight =parseDouble(Weight.getText().toString());
EditText Height = (EditText) findViewById(R.id.HeightID);
tempHeight = parseDouble(Height.getText().toString());
EditText checkWeight = (EditText) findViewById(R.id.WeightID);
ifEmptyWeight=checkWeight.getText().toString();
EditText checkHeight = (EditText)findViewById(R.id.HeightID);
ifEmptyHeight=checkHeight.getText().toString();
if(ifEmptyHeight.length()<1)
{
Toast emptyHeight = Toast.makeText(MainActivity.this,"Height TextBox is Empty",Toast.LENGTH_SHORT);
emptyHeight.show();
}
else if(ifEmptyWeight.length()<1)
{
Toast emptyWeight = Toast.makeText(MainActivity.this,"Weight TextBox is Empty",Toast.LENGTH_SHORT);
emptyWeight.show();
}
else {
YourBMI = tempWeight / ((tempHeight * tempHeight) / 10000);
Intent intent = new Intent(MainActivity.this, Druga.class);
intent.putExtra("BMI", YourBMI);
startActivity(intent);
}
Logi:
06-24 08:18:53.256 1897-1897/com.example.miloszex.kalkulatorbmi E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.miloszex.kalkulatorbmi, PID: 1897
java.lang.IllegalStateException: Could not execute method of the activity
at android.view.View$1.onClick(View.java:4007)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4002)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
Caused by: java.lang.NumberFormatException: Invalid double: ""
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:267)
at java.lang.Double.parseDouble(Double.java:301)
at com.example.miloszex.kalkulatorbmi.MainActivity.Oblicz_BMI(MainActivity.java:55)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at android.view.View$1.onClick(View.java:4002)
at android.view.View.performClick(View.java:4756)
at android.view.View$PerformClick.run(View.java:19749)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)