So I’ve been following the time picker tutorial step by step to be found here.
Even though I went over the code again and again I can’t spot where I supposedly made a mistake, I keep getting “Syntax error on token “}”, delete this token” on the last token of the code file that you can see here:
public class ReportsActivity extends Activity {
//Set up variables for the time change button
private TextView mTimeDisplay;
private Button mPickTime;
private int mHour;
private int mMinute;
static final int TIME_DIALOG_ID = 0;
//updates time displayed in textview
private void updateDisplay(){
mTimeDisplay.setText(
new StringBuilder()
.append(pad(mHour)).append(":")
.append(pad(mMinute)));
}
private static String pad(int c){
if (c >= 10)
return String.valueOf(c);
else
return "0" + String.valueOf(c);
}
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.report);
//TIME CHANGE IMPLEMENTATION
//Capturing View elements
mTimeDisplay = (TextView) findViewById(R.id.timeDisplay);
mPickTime = (Button) findViewById(R.id.buttonTime);
//add click listener to the button
mPickTime.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
showDialog(TIME_DIALOG_ID);
}
});
//current time
final Calendar c = Calendar.getInstance();
mHour = c.get(Calendar.HOUR_OF_DAY);
mMinute = c.get(Calendar.MINUTE);
//display current
updateDisplay();
}
private TimePickerDialog.OnTimeSetListener mTimeSetListener =
new TimePickerDialog.OnTimeSetListener(){
public void onTimeSet(TimePicker view, int hourOfDay, int minute){
mHour = hourOfDay;
mMinute = minute;
updateDisplay();
}
};
@Override
protected Dialog onCreateDialog(int id){
switch (id) {
case TIME_DIALOG_ID:
return new TimePickerDialog(this, mTimeSetListener, mHour, mMinute, false);
}
return null;
}
}
} //Here is where I get the error message
Thanks for the help in advance.
Remove last } . Its an extra one ..