Learn Pain Less

HomeOur TeamContact
Android
EditText editable deprecated android | How to use inputType in Android
Pawneshwer Gupta
Pawneshwer Gupta
July 26, 2020
1 min

Table Of Contents

01
EditText editable is deprecated How to use inputType in Android
02
Make EditText non editable in Android
EditText editable deprecated android | How to use inputType in Android

EditText editable is deprecated How to use inputType in Android

If you are working in non editable EditText, then you may notice that now it’s showing warning in xml layout file, Because android:editable is now editable deprecated android. And it will be removed in upcoming version of android. And if you navigate to official website then they will suggest you to use android:inputType instead of android:editable. But they haven’t explained that how to use android:inputType to disable input in EditText.

So here is solution:

Make EditText non editable in Android

First method:

first method is using android:inputType which is suggested by official android team. To use this just set android:inputType="none" and it will become non editable.

for example

in XML
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint"
android:inputType="none"
/>

Second method:

In your xml code set focusable="false", android:clickable="false" and android:cursorVisible="false" and this will make your EditText treat like non editable.

for example

in XML
<EditText
android:id="@+id/myEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Hint"
android:focusable="false"
android:clickable="false"
android:cursorVisible="false"
/>

Third method:

If you can also disable EditText, then you can set this from Java or Kotlin code.

for example

In Java
EditText et = findViewById(R.id.myEditText);
et.setEnabled(false);
In Kotlin
myEditText.isEnabled = false
It depends on you that which method will you preffer. Write in comments which method you like and why?, so other users can take benefit of this.

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

EditTextandroid

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

How to use Text To Speech inside RecyclerView in Android
How to use Text To Speech inside RecyclerView in Android
July 27, 2020
1 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media