所以我一直按照时间选择器教程一步一步地在这里找到。即使我一遍又一遍地查看代码,但我无法发现我应该在哪里犯了错误,我不断收到“令牌“}”上的语法错误,删除这个令牌”在您可以看到的代码文件的最后一个令牌上这里:
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
我在这里先向您的帮助表示感谢。