How to disable EditText in Android

前端 未结 18 1920
后悔当初
后悔当初 2020-12-13 12:03

How can I disable typing in an EditText field in Android?

相关标签:
18条回答
  • 2020-12-13 12:38

    You can write edittext.setInputType(0) if you want to show the edittext but not input any values

    0 讨论(0)
  • 2020-12-13 12:39

    you can use EditText.setFocusable(false) to disable editing
    EditText.setFocusableInTouchMode(true) to enable editing;

    0 讨论(0)
  • 2020-12-13 12:39

    Assuming editText is you EditText object:

    editText.setEnabled(false);
    
    0 讨论(0)
  • 2020-12-13 12:40

    The XML editable property is deprecated since API LEVEL 15.

    You should use now the inputType property with the value none. But there is a bug that makes this functionality useless.

    Here you can follow the issue status.

    0 讨论(0)
  • 2020-12-13 12:41

    The below code disables the EditText in android

    editText.setEnabled(false);
    
    0 讨论(0)
  • 2020-12-13 12:42

    To disable a edittext in android:

    editText.setEnabled(false);
    
    0 讨论(0)
提交回复
热议问题