Why am I getting an java.lang.runtimeexception: Unable to instantiate activityComponentInfo {com.example.carprofile/com.example.carprofile.CarRegistraion}: java.lang.NullPointerExceprion
This is my code:
public class CarRegistration extends Activity{
//ParseXML parseClass;
Button saveCar;
EditText carMake = (EditText) findViewById(R.id.etCarMake);
EditText carModel = (EditText) findViewById(R.id.etCarModel);
String newCar;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.car_registration);
saveCar = (Button) findViewById(R.id.bSaveCar);
saveCar.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
newCar = carMake.getText() +" "+ carModel.getText();
//parseClass = new ParseXML(newCar);
//parseClass.editXML();
}
});
}
if I clear the onCreate method, from saveCar = (Button)..., everything works fine.
Can someone tell me what am I doing wrong?