0
每當我嘗試運行我的應用程序時,LogCat中都會顯示一個錯誤。這是我在MainActivity.javaE/AndroidRuntime:致命例外:main
package com.practice.bludworth.practiceapp;
import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText ageInput = (EditText) findViewById(R.id.ageReceived);
int input = Integer.parseInt(ageInput.getText().toString());
}
@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;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
}
代碼logcat的錯誤說這是:
Caused by: java.lang.NumberFormatException: Invalid int: ""
很困惑,因爲我一般是新的節目。謝謝
有意義。那麼我應該把這個代碼放在哪裏?對不起,這很新鮮。謝謝 – user3808555 2014-10-19 00:40:35