AndroidSmile.com AndroidSmile.com - 1 year ago 167
Android Question

How to set InputType 'time' programmatically?

I could set

InputType
'time' in XML

<EditText
android:inputType="time"
android:layout_width="match_parent"
android:layout_height="wrap_content" />


I need a keyboard, which shows
digits
and
colon(:)
. How to set
InputType
'time' programmatically?

Answer Source

For time field:

 setInputType(InputType.TYPE_CLASS_DATETIME |InputType.TYPE_DATETIME_VARIATION_TIME);

datetime has dot(.), slash(/) which I do not want to show in keyboard

You should try with

setKeyListener(DigitsKeyListener.getInstance("0123456789:"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download