app:core_style=”0” (默认)
    image.png
    app:core_style=”1”
    image.png

    1. <me.luzhuo.lib_core.ui.widget.YearMonthDayView
    2. android:id="@+id/ymd"
    3. android:layout_width="wrap_content"
    4. android:layout_height="wrap_content"
    5. app:core_style="1"
    6. app:core_mode="year|month|day|hour|minute|second"
    7. app:layout_constraintBottom_toBottomOf="parent"
    8. app:layout_constraintLeft_toLeftOf="parent"
    9. app:layout_constraintRight_toRightOf="parent"
    10. app:layout_constraintTop_toTopOf="parent" />
    1. public class MainActivity extends AppCompatActivity {
    2. private static final String TAG = MainActivity.class.getSimpleName();
    3. private YearMonthDayView yearView;
    4. @Override
    5. protected void onCreate(Bundle savedInstanceState) {
    6. super.onCreate(savedInstanceState);
    7. setContentView(R.layout.activity_main);
    8. yearView = findViewById(R.id.ymd);
    9. yearView.setMode(YearMonthDayView.Mode_Year|YearMonthDayView.Mode_Month|YearMonthDayView.Mode_Day|YearMonthDayView.Mode_Hour|YearMonthDayView.Mode_Minute);
    10. yearView.setDateChangeCallback(new YearMonthDayView.OnDateChangeCallback() {
    11. @Override
    12. public void onDatePicker(int year, int month, int day) {
    13. Log.e(TAG, "" + year + " : " + month + " : " + day);
    14. }
    15. @Override
    16. public void onTimePicker(int hour, int minute) {
    17. Log.e(TAG, "" + hour + " : " + minute);
    18. }
    19. });
    20. }
    21. public void onclick(View view) {
    22. Log.e(TAG, "" + yearView.year());
    23. Log.e(TAG, "" + yearView.month());
    24. Log.e(TAG, "" + yearView.day());
    25. Log.e(TAG, "" + yearView.hour());
    26. Log.e(TAG, "" + yearView.minute());
    27. Log.e(TAG, "" + yearView.second());
    28. Log.e(TAG, "" + yearView.time());
    29. }
    30. }