It looks like this line
tripsNumberEditText.setText(TOTAL_TRIPS);
is giving your NPE
because you haven't yet initialized it. Move this line below the initialization
tripsNumberEditText = (EditText) findViewById(R.id.tripsNumberEditText);
tripsNumberEditText.setText(TOTAL_TRIPS);
Will be your next error
Also, you are using the wrong setText()
method. You are giving it an int
which will tell it to look for a resource
with that id
which it obviously won't find. You need to change it to a String
with something like
tripsNumberEditText.setText("" + TOTAL_TRIPS);
Furthermore, since you are setting the text in onCreate()
before the user has a chance to give any input, you could also set it in your xml with
android:text="0"
Note if you use a hard-coded string like this Eclipse will give you a warning which would be ok but better to define the value in strings.xml
.