カレンダービューから1つの日付を選択するためのスタンドアロンAndroidウィジェット。
レイアウトXMLにCalendarPickerView
含めます。
< com .squareup.timessquare.CalendarPickerView
android : id = " @+id/calendar_view "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
/>
これはかなり大きなコントロールなので、レイアウトに十分なスペースを与えることが賢明です。小さなデバイスでは、ダイアログ、フルスクリーンフラグメント、または専用のアクティビティを使用することをお勧めします。タブレットのような大規模なデバイスでは、フルスクリーンを表示することはお勧めしません。レイアウトまたはダイアログの一部を占めるフラグメントがより良い選択です。
アクティビティ/ダイアログのonCreate
またはフラグメントのonCreateView
の概要では、現在選択されている日付の範囲でビューを初期化します。
Calendar nextYear = Calendar . getInstance ();
nextYear . add ( Calendar . YEAR , 1 );
CalendarPickerView calendar = ( CalendarPickerView ) findViewById ( R . id . calendar_view );
Date today = new Date ();
calendar . init ( today , nextYear . getTime ())
. withSelectedDate ( today );
ビューのデフォルトモードは、選択可能な日付を1つ持つことです。ユーザーに複数の日付または日付範囲を選択できるようにしたい場合は、InMode()メソッドを使用します。
calendar . init ( today , nextYear . getTime ())
. inMode ( RANGE );
最新バージョンはZIPでダウンロードし、アプリケーションからライブラリプロジェクトとして参照できます。
Mavenを介してライブラリに依存することもできます。
< dependency >
< groupId >com.squareup</ groupId >
< artifactId >android-times-square</ artifactId >
< version >1.6.5</ version >
< type >apklib</ type >
</ dependency >
またはGradle:
compile ' com.squareup:android-times-square:1.6.5@aar '
開発バージョンのスナップショットは、Sonatypeのsnapshots
リポジトリで入手できます。
Copyright 2012 Square, Inc.
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.