Calendar on Android

Asked

Viewed 73 times

0

Hello personal I am new here and forgive me for some immaturity in the area of programming for Android. The business is the following I am developing an application that needs to pick a date, so my idea is a kind of button where it opens a calendar (current) and the person can choose a day equal to "Jcalendar" Java, I don’t know if you can understand my question but I’m waiting for the answers.... From now on I thank you for everything...

  • Welcome, I recommend making a [tour], and edit your question not to be closed as wide as too, good luck.

  • Jorge around here likes you to post what exactly you’ve done and specifically show your problem. A broad question like this is not very well accepted, it doesn’t make a good impression. In fact a broad question like this google answers without problems: https://www.google.com/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=Calendar+android+example&*

  • Thank you so much for the information... it’s the fault of inexperience I’m still adapting the questions ...

2 answers

1

I don’t know if it’s what you need, but I also had to work with calendar and I found this library very good:

https://github.com/shrikanth7698/Collapsible-Calendar-View-Android

final CollapsibleCalendar collapsibleCalendar = findViewById(R.id.calendarView);

collapsibleCalendar.setCalendarListener(new CollapsibleCalendar.CalendarListener() {

    @Override
    public void onDaySelect() {
        Day day = viewCalendar.getSelectedDay();
        Log.i(getClass().getName(), "Selected Day: "
                + day.getYear() + "/" + (day.getMonth() + 1) + "/" + day.getDay());
    }

    @Override
    public void onItemClick(View view) {

    }

    @Override
    public void onDataUpdate() {

    }

    @Override
    public void onMonthChange() {

    }

    @Override
    public void onWeekChange(int i) {

    }
});
  • @Barbetta amended answer

0

I developed a similar screen once. The layout can be what you imagine. follows the low the methods I did to call the android calendar and capture the date selected by the user in an Edit.

edt_data = (EditText)findViewById(R.id.edt_data);
bCalendario= (Button)findViewById(R.id.b_calendario);
bCalendario.setOnClickListener(new View.OnClickListener()   {
  @SuppressWarnings("deprecation")
  public void onClick(View v)  {
    showDialog(DATE_DIALOG_ID); //chamar o calendario
  }
});

@Override
protected Dialog onCreateDialog(int id) {
  switch (id) {
    case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener,mYear, mMonth-1, mDay);
  }
  return null;
}

private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() {
  public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
    mYear = year;
    mMonth = monthOfYear;
    mDay = dayOfMonth;
    updateDisplay();
  }
};

private void updateDisplay() {
        edt_data.setText(new StringBuilder()
                // Month is 0 based so add 1
                .append(mDay).append("/")
                .append(mMonth + 1).append("/")
                .append(mYear).append(" "));
    }
  • 1

    Thank you very much for the response and attention of colleagues... I will be doing the tests and publish the result soon...;)

  • I would just like to ask one more question: As stated by the "DATE_DIALOG_ID"

  • is an Integer variable

Browser other questions tagged

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