How to make an edittext editable on long click

Viewed 29

I want to make edit text editable only when we long click on that edit text. The editable method is deprecated so I tried this to disable the edit property of edit text and enable it on Long Click.

        <EditText
        android:id="@+id/name"
        android:clickable="false"
        android:focusable="false"
        android:cursorVisible="false"/>

        binding.name.setOnLongClickListener{
          binding.name.isCursorVisible = true
          binding.name.isClickable = true
          binding.name.isFocusable = true
          true
        }

This is not working. How can we implement this? Are there any methods to use other than 'editable'?

0 Answers
Related