How to disable EditText in Android

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

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

18条回答
  •  爱一瞬间的悲伤
    2020-12-13 12:20

    According to me...if you have already declared the edittext in the XML file and set the property in the XML file "android:enabled=false" and disable at runtime to it at that time in java file adding only 2 or 3 lines

    1. First create the object
    2. Declare EditText et1;
    3. Get by id

      et1 = (EditText) FindViewById(R.id.edittext1);
      et1.setEnabled(false);

    You can do enable or disable to every control at run time by java file and design time by XML file.

提交回复
热议问题