Eigenes Android -Widget zum Auswählen eines einzelnen Datums aus einer Kalenderansicht.
CalendarPickerView
in Ihr Layout XML aufnehmen.
< com .squareup.timessquare.CalendarPickerView
android : id = " @+id/calendar_view "
android : layout_width = " match_parent "
android : layout_height = " match_parent "
/>
Dies ist eine ziemlich große Kontrolle, daher ist es ratsam, ihm in Ihrem Layout ausreichend Platz zu geben. Auf kleinen Geräten wird empfohlen, einen Dialog, einen Vollbildfragment oder eine dedizierte Aktivität zu verwenden. Auf größeren Geräten wie Tablets wird nicht empfohlen. Ein Fragment, das einen Teil des Layouts oder eines Dialogs besetzt, ist eine bessere Wahl.
In der onCreate
Ihres Aktivität/Ihres Dialogfelds oder der onCreateView
Ihres Fragments initialisieren Sie die Ansicht mit einem Bereich gültiger Daten sowie dem aktuell ausgewählten Datum.
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 );
Der Standardmodus der Ansicht besteht darin, ein ausgewähltes Datum zu haben. Wenn der Benutzer in der Lage ist, mehrere Daten oder einen Datumsbereich auszuwählen, verwenden Sie die Methode inMode ():
calendar . init ( today , nextYear . getTime ())
. inMode ( RANGE );
Die neueste Version kann in ZIP heruntergeladen und von Ihrer Anwendung als Bibliotheksprojekt verwiesen werden.
Sie können sich auch über Maven auf die Bibliothek verlassen:
< dependency >
< groupId >com.squareup</ groupId >
< artifactId >android-times-square</ artifactId >
< version >1.6.5</ version >
< type >apklib</ type >
</ dependency >
oder Gradle:
compile ' com.squareup:android-times-square:1.6.5@aar '
Snapshots der Entwicklungsversion sind im snapshots
-Repository von Sonatype verfügbar.
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.