0
I took it that code which to some extent worked. But the method updateLabel
I can’t do it because of the problem:
I need to get the selected calendar date. I’m using a way that by clicking on editText, the calendar opens.
final DatePickerDialog.OnDateSetListener date = new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
// TODO Auto-generated method stub
myCalendar.set(Calendar.YEAR, year);
myCalendar.set(Calendar.MONTH, monthOfYear);
myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
updateLabel(myCalendar);
}
};
editText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new DatePickerDialog(AgendamentoActivity.this, date, myCalendar
.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
myCalendar.get(Calendar.DAY_OF_MONTH)).show();
//Toast.makeText(getBaseContext(), "8:00 - 9:00", Toast.LENGTH_LONG).show();
}
});
private void updateLabel(Calendar) {
SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd hh:mm:ss 'GMT'Z yyyy");
System.out.println(dateFormat.format(myCalendar.getTime()));
//editText.setText(sdf.format(myCalendar.getTime()));
}
No, it’s all out of the onCreate.
– GustavoSevero
@Gustavosevero you have to put the code in the question and not the code image. It is easier to help you.
– viana
I put the part of the code that’s going wrong above the photo
– GustavoSevero
@Gustavosevero only this can not find the error. ehe
– viana
Now I’ve put all the code
– GustavoSevero
Dude, the mistake is exactly what I’m telling you. You’re putting the method in the wrong place. Part of that there should be inside the oncreate and only the updateLabel method could be outside.
– viana
Okay, I’ll try that.
– GustavoSevero
It worked kkkkk Now it’s giving another error after I select the date and click OK.
– GustavoSevero
Does not recognise this method: Simpledateformat dateFormat = new Simpledateformat("EEE MMM dd hh:mm:ss 'GMT'Z yyyy");
– GustavoSevero
@Gustavosevero this then would be another mistake! If you want to validate this answer and ask another question with the new error! = D
– viana
Blz, that’s what I’m gonna do.
– GustavoSevero
@Gustavosevero good luck ai! = D
– viana