編集テキスト値をフロートに割り当てようとすると、アプリが強制終了します。これがコードです。Float.valueOf() の代わりに Float.parseFloat() メソッドも試しました。getETvalue() メソッドを外すと、アプリは機能します。助けてください
package com.example.aviator_18;
import android.os.Bundle;
import android.app.Activity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
public class MainActivity extends Activity {
float Remaining,Departure,TotUplift,SG,DiscResult;
int CalUpliftResult;
TextView RemainingTV,DepartureTV,UpliftTV,SGtv,CalcUpliftTV,DiscrepancyTV;
EditText RemainingET,DepartureET,TotUpliftET,SGet,CalcUpliftET,DiscrepancyET;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setupView();
getETvalue();
evaluation();
CalcUpliftTV.setText(String.valueOf(CalUpliftResult));
DiscrepancyTV.setText(String.valueOf(DiscResult));
}
private void getETvalue() {
String a,b,c,d,e;
Remaining=Float.valueOf(RemainingET.getText().toString());
Departure=Float.valueOf(DepartureET.getText().toString());
TotUplift=Float.valueOf(TotUpliftET.getText().toString());
SG=Float.valueOf(SGet.getText().toString());
}
private void evaluation() {
CalUpliftResult=Math.round(TotUplift*SG);
DiscResult=((Departure-Remaining-CalUpliftResult)/CalUpliftResult)*100;
}
private void setupView() {
RemainingET=(EditText)findViewById(R.id.remainingET);
DepartureET=(EditText)findViewById(R.id.departureET);
TotUpliftET=(EditText)findViewById(R.id.TotalUpliftET);
SGet=(EditText)findViewById(R.id.SGet);
CalcUpliftTV=(TextView)findViewById(R.id.CalUpliftResult);
DiscrepancyTV=(TextView)findViewById(R.id.discResult);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
}