'Convert EditText to TextView Programatically? [duplicate]

What I Want

I want to convert EditText into TextView programmatically.

<EditText
    android:id="@+id/inputValue"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:inputType="number" />

how can I convert the above EditText to below TextView

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="TextView" />


Solution 1:[1]

  1. You can use 1 edittext and 1 Textview on same postion and hide them according to your need

    or

  2. You can use editText.setEnabled(false);

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1