Also ich habe ein Problem ich bin beim ausprobieren von java und android studio aber ich habe ein Problem, dass ich mir nicht erklären kann....
package com.example.misa.wiederholung;
import android.annotation.SuppressLint;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class second extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
Button neue;
EditText exponent1;
EditText exponent2;
EditText exponent3;
neue=(Button) findViewById(R.id.neue);
exponent1=(EditText)findViewById(R.id.Exponent1);
exponent2=(EditText)findViewById(R.id.Exponent2);
exponent3=(EditText)findViewById(R.id.Exponent3);
final float expo1=Float.parseFloat(exponent1.getText().toString());
final float expo2=Float.parseFloat(exponent2.getText().toString());
final float expo3=Float.parseFloat(exponent3.getText().toString());
neue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (expo1==2.0 && expo2==0.0 && expo3==0.0 ){
dieseMässig();
}
}
});
}
public void dieseMässig(){
Button neue;
final TextView zweiteableitung;
final TextView eanull;
final TextView zweiterschritt;
final TextView macher1;
final TextView macher2;
final TextView macher3;
final TextView macher4;
final TextView machererg1;
final TextView machererg2;
final TextView ersteableitung;
final TextView tphp;
final EditText operantText2;
final EditText operantText3;
final EditText operantText1;
final EditText exponent1;
final EditText exponent2;
final EditText exponent3;
neue=(Button) findViewById(R.id.neue);
operantText1=(EditText) findViewById(R.id.etOperant1);
operantText2=(EditText)findViewById(R.id.etOperant2);
operantText3=(EditText)findViewById(R.id.etOperant3);
macher1=(TextView)findViewById(R.id.Macher1);
macher2=(TextView)findViewById(R.id.Macher2);
macher3=(TextView)findViewById(R.id.Macher3);
macher4=(TextView)findViewById(R.id.Macher4);
machererg1=(TextView)findViewById(R.id.myErg1);
machererg2=(TextView)findViewById(R.id.myErg2);
ersteableitung=(TextView)findViewById(R.id.ersteableitung);
zweiteableitung=(TextView)findViewById(R.id.zweiteableitung);
eanull=(TextView)findViewById(R.id.eanull);
zweiterschritt=(TextView)findViewById(R.id.ersterschritt);
tphp=(TextView)findViewById(R.id.tphp);
exponent1=(EditText)findViewById(R.id.Exponent1);
exponent2=(EditText)findViewById(R.id.Exponent2);
exponent3=(EditText)findViewById(R.id.Exponent3);
final float expo1=Float.parseFloat(exponent1.getText().toString());
final float expo2=Float.parseFloat(exponent2.getText().toString());
final float expo3=Float.parseFloat(exponent3.getText().toString());
neue.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
{
String a="f(x)=";
String b="x²+";
String c="x+";
String d="0";
String e="=";
String g="x1,x2=";
float wert1=Float.parseFloat(operantText1.getText().toString());
float wert2=Float.parseFloat(operantText2.getText().toString());
float wert3=Float.parseFloat(operantText3.getText().toString());
macher1.setText(a + wert1 + b + wert2 + c + wert3);
macher2.setText(d+e+wert1+b+wert2+c+wert3);
float f=2;
float b_3=-(wert2/f);
float b_2= (float) Math.pow(-(wert2/2), 2 );
float quadratwurzel= (float) Math.sqrt(b_2-wert3);
String str3=String.valueOf(b_3);
macher3.setText(g+b_3+"+/-"+quadratwurzel);
float erg1=b_3+quadratwurzel;
float erg2=b_3-quadratwurzel;
macher4.setText(g+erg1+" v "+erg2);
machererg1.setText("x1="+erg1);
machererg2.setText("x");
}
}
});
}
}Als Fehler kommt mir dies raus...02-17 19:11:56.263 23077-23077/com.example.wiederholung E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.misa.wiederholung, PID: 23077
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.misa.wiederholung/com.example.misa.wiederholung.second}: java.lang.NumberFormatException: Invalid float: ""
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2325)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Caused by: java.lang.NumberFormatException: Invalid float: ""
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseFloat(StringToReal.java:308)
at java.lang.Float.parseFloat(Float.java:306)
at com.example.misa.wiederholung.second.onCreate(second.java:29)
at android.app.Activity.performCreate(Activity.java:5990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2278)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2387)
at android.app.ActivityThread.access$800(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1303)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5254)
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:903)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Ich hoffe ihr könnt mir helfen