1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/chinasoft_ohos-datetimepicker

Клонировать/Скачать
README.md 6.4 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
gitlife-traslator Отправлено 26.11.2024 14:04 51bdc04

Проект datetimepicker

Проект

  • Название проекта: datetimepicker.
  • Серия: openharmony, сторонние компоненты для адаптации.
  • Функция: настраиваемый компонент выбора времени и даты.
  • Состояние переноса: основная функция выполнена.
  • Различия в вызовах: отсутствуют.
  • Версия разработки: SDK6, DevEco Studio 2.2 Beta1.
  • Базовая версия: Release 0.0.2.

Демонстрация эффекта

sc1

Инструкция по установке

Добавьте зависимость в файл build.gradle на уровне модуля:

// Добавляем maven-репозиторий
repositories {
    maven {
        url 'https://s01.oss.sonatype.org/content/repositories/releases/'
    }
}

// Добавляем библиотеку зависимостей
dependencies {
    implementation 'com.gitee.chinasoft_ohos:datetimepicker:1.0.0'   
}

Проект можно запустить напрямую в SDK6 и DevEco Studio 2.2 Beta1. Если запуск не удаётся, удалите файлы .gradle, .idea, build, gradle, build.gradle и создайте новый проект с соответствующей версией. Скопируйте файлы из нового проекта в корневой каталог.

Использование

  <Button
            ohos:id="$+id:dateButton"
            ohos:width="match_content"
            ohos:height="match_content"
            ohos:background_element="#d6d6d6"
            ohos:padding="9vp"
            ohos:text_size="20fp"
            ohos:text="Select Date"
            ohos:bottom_margin="30vp"/>

        <Checkbox
            ohos:width="match_content"
            ohos:height="match_content"
            ohos:text="close on single tap minute"
            ohos:bottom_margin="30vp"
            ohos:text_size="15fp"
            ohos:id="$+id:checkBoxCloseOnSingleTapMinute"
            ohos:marked="true"/>

        <Button
            ohos:id="$+id:timeButton"
            ohos:width="match_content"
            ohos:height="match_content"
            ohos:background_element="#d6d6d6"
            ohos:padding="9vp"
            ohos:text_size="20fp"
            ohos:text="Select Time"
            ohos:bottom_margin="30vp"/>
  • Пример использования Java*
           
// step1 :
          public class SecondAbilitySlice extends AbilitySlice
                  implements DatePickerDialog.OnDateSetListener, TimePickerDialog.OnTimeSetListener

// step2 :
          findComponentById(ResourceTable.Id_dateButton).setClickedListener(new Component.ClickedListener() {
                    @Override
                    public void onClick(Component component) {
                        showdate();
                    }
                });
        
                findComponentById(ResourceTable.Id_timeButton).setClickedListener(new Component.ClickedListener() {
                    @Override
                    public void onClick(Component component) {
                      showtime();
                    }
                });
// step3:
      private void showdate() {
            datePickerDialog = DatePickerDialog.newInstance(this,SecondAbilitySlice.this,
                calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH),
                isVibrate());
            datePickerDialog.setVibrate(isVibra);
            datePickerDialog.setYearRange(1985,2028);
            datePickerDialog.setCloseOnSingleTapDay(isCloseOnSingleTapDay());
            datePickerDialog.setOnDateSetListener(this);
            datePickerDialog.show();
        }
        
    private void showtime() {
           timePickerDialog = TimePickerDialog.newInstance((TimePickerDialog.OnTimeSetListener) this,
               SecondAbilitySlice.this, calendar.get(Calendar.HOUR_OF_DAY),
               calendar.get(Calendar.MINUTE), false, false);
           timePickerDialog.setVibrate(isVibrate());
           timePickerDialog.setCloseOnSingleTapMinute(isCloseOnSingleTapMinute());
           timePickerDialog.setOnTimeSetListener(this);
           timePickerDialog.show();
       }
    
//step4: 通过onTimeSet 和 onDateSet获取设定的时间和 дату данные
  public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) {
        new ToastsUtils.Builder(getContext())
            .setToastText("new time:" + hourOfDay + "-"
                + minute).setDuration(2000)
            .build().show();
    }

 public void onDateSet(DatePickerDialog datePickerDialog, int year, int month, int day) {
        new ToastsUtils.Builder(getContext())
            .setToastText("new date:"
                + year + "-" + (month + 1) + "-" + day).setDuration(2000)
            .build().show();
    }

Тестирование

CodeCheck — код протестирован, исключений нет. Тест CloudTest кода не выявил аномалий.

Вирусное сканирование прошло успешно.

Текущая версия demo не отличается от оригинального компонента Android.

Версия

1.0.0

Авторские права и лицензии

Copyright 2013 Flavien Laurent (DatePicker) edisonw (TimePicker).

Licensed under the Apache License, Version 2.0 (the «License»); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an «AS IS» BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/chinasoft_ohos-datetimepicker.git
git@api.gitlife.ru:oschina-mirror/chinasoft_ohos-datetimepicker.git
oschina-mirror
chinasoft_ohos-datetimepicker
chinasoft_ohos-datetimepicker
master