Custom Android calendarView

前端 未结 2 1558
难免孤独
难免孤独 2020-12-07 10:36

I am looking for a CalendarView that can be used in a dialog something like this:

\"\"

I plan to use

2条回答
  •  暖寄归人
    2020-12-07 11:22

    Hi visit all given links, hope will help you

    1. Betterpickers: https://github.com/derekbrameyer/android-betterpickers

    2. Calendar Sync: http://www.androiddevelopersolutions.com/2013/05/android-calendar-sync.html

    3. Simple Calendar: http://w2davids.wordpress.com/android-simple-calendar/

    4. Caldroid: https://github.com/roomorama/Caldroid

    5. DateTimePicker: https://github.com/flavienlaurent/datetimepicker

    When you visit Betterpickers, for a working implementation of this project see the sample/ folder.

    Implement the appropriate Handler callbacks:

    public class MyActivity extends Activity implements DatePickerDialogFragment.DatePickerDialogHandler {
    
      @Override
      public void onCreate(Bundle savedInstanceState) {
        // ...
      }
    
      @Override
      public void onDialogDateSet(int year, int monthOfYear, int dayOfMonth) {
        // Do something with your date!
      }
    }
    

    Use one of the Builder classes to create a PickerDialog with a theme:

    DatePickerBuilder dpb = new DatePickerBuilder()
        .setFragmentManager(getSupportFragmentManager())
        .setStyleResId(R.style.BetterPickersDialogFragment);
    dpb.show();
    

    Also for another example you can visit Caldroid and use as follows:

    To embed the Caldroid fragment in your activity, use below code:

    CaldroidFragment caldroidFragment = new CaldroidFragment();
    Bundle args = new Bundle();
    Calendar cal = Calendar.getInstance();
    args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
    args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
    caldroidFragment.setArguments(args);
    
    FragmentTransaction t = getSupportFragmentManager().beginTransaction();
    t.replace(R.id.calendar1, caldroidFragment);
    t.commit();
    

提交回复
热议问题