DateKeyListener.java revision 54b6cfa9a9e5b861a9930af873580d6dc20f773c
1/* 2 * Copyright (C) 2006 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17package android.text.method; 18 19import android.view.KeyEvent; 20 21/** 22 * For entering dates in a text field. 23 */ 24public class DateKeyListener extends NumberKeyListener 25{ 26 @Override 27 protected char[] getAcceptedChars() 28 { 29 return CHARACTERS; 30 } 31 32 public static DateKeyListener getInstance() { 33 if (sInstance != null) 34 return sInstance; 35 36 sInstance = new DateKeyListener(); 37 return sInstance; 38 } 39 40 /** 41 * The characters that are used. 42 * 43 * @see KeyEvent#getMatch 44 * @see #getAcceptedChars 45 */ 46 public static final char[] CHARACTERS = new char[] { 47 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 48 '/', '-', '.' 49 }; 50 51 private static DateKeyListener sInstance; 52} 53