How to prevent the user from typing in EditText, but allow clicking on it to open a DatePicker?

2

I have an EditText that when clicking it opens a DatePicker, how do I prevent the user from typing in EditText? I tried to use edtData.setEnable (false) but when clicking on editText nothing happens.

    
asked by anonymous 15.10.2017 / 00:46

2 answers

2

Add to EditText the following:

android:focusable="false"

This will prevent EditText from getting focus , not allowing you to type in it.

Alternatively use a TextView instead of EditText.

For TextView to look like an EditText use:

style="@android:style/Widget.EditText"
    
15.10.2017 / 13:30
1

To avoid editing in EditText set KeyListener to null

edtData.setKeyListener(null);
    
16.10.2017 / 12:58