"Expression expected" error

Asked

Viewed 1,220 times

0

I took it that code which to some extent worked. But the method updateLabel I can’t do it because of the problem:

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

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()));
    }

2 answers

2


It seems to me you’re putting your method updateLabel() within the onCreate when you should actually be out. See an example:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

public void updateLabel(){
    // aqui você coloca o código desejado
}
  • No, it’s all out of the onCreate.

  • @Gustavosevero you have to put the code in the question and not the code image. It is easier to help you.

  • I put the part of the code that’s going wrong above the photo

  • @Gustavosevero only this can not find the error. ehe

  • Now I’ve put all the code

  • 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.

  • Okay, I’ll try that.

  • It worked kkkkk Now it’s giving another error after I select the date and click OK.

  • Does not recognise this method: Simpledateformat dateFormat = new Simpledateformat("EEE MMM dd hh:mm:ss 'GMT'Z yyyy");

  • @Gustavosevero this then would be another mistake! If you want to validate this answer and ask another question with the new error! = D

  • Blz, that’s what I’m gonna do.

  • @Gustavosevero good luck ai! = D

Show 7 more comments

0

Get your Calendar in updateLabel(Calendar myCalendar) and pass as argument to that same method within the onDateSet.

  • I put the new wrong that gives, after doing what you suggested. See in the description of the post.

  • I could post it all?

  • I put all the code

Browser other questions tagged

You are not signed in. Login or sign up in order to post.