Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

java.lang.RuntimeException: Unable to start activity ComponentInfo { com.project/com.project.simple} : java.lang.NumberFormatException

EditText et1,et2,et3;
Button b1, b2;
Float two,three,four;   
@Override
protected void onCreate(Bundle savedInstanceState) {

// TODO Auto-generated method stub

super.onCreate(savedInstanceState);

setContentView(R.layout.can);

et1 = (EditText) findViewById(R.id.editText1);

two = Float.valueOf(et1.getText().toString());

et2 = (EditText) findViewById(R.id.editText2);

three = Float.valueOf(et2.getText().toString());

et3 = (EditText) findViewById(R.id.editText3);

four = Float.valueOf(et3.getText().toString());

    b1 = (Button) findViewById(R.id.button1);

b2 = (Button) findViewById(R.id.button2);

b1.setOnClickListener(new OnClickListener() {
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
163 views
Welcome To Ask or Share your Answers For Others

1 Answer

you are in onCreate() where the fields are specified. the user could not have time to enter any valid data. you need to move the fetching of the data somewhere else...like your onClick() perhaps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...