วิดเจ็ต Android แบบสแตนด์อโลนสำหรับการเลือกวันที่เดียวจากมุมมองปฏิทิน
รวม CalendarPickerView
ใน Layout XML ของคุณ
< 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 );
โหมดเริ่มต้นของมุมมองคือการมีวันที่เลือกได้หนึ่งวัน หากคุณต้องการให้ผู้ใช้สามารถเลือกหลายวันหรือช่วงวันที่ให้ใช้เมธอด 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 '
สแน็ปช็อตของเวอร์ชันการพัฒนามีอยู่ในที่เก็บ snapshots
ของ Sonatype
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.