How to make Edittext can be marked only programmatically?

66 views Asked by At

I wanna have an EditText which can be updated only programmatically. When I click on it, I will not be able to enter anything, but when I click the button with requestFocus to this EditText I want to have that option.

I tried android:focusableInTouchMode="true", but in this case, I can't use EditText when I click button either.

Any ideas?

2

There are 2 answers

0
Bruno On

You can enable or disable the EditText.

android:enabled="false"

And when you click on your button, you have to do :

myEditText.setEnabled(true)
0
Justwell Solets On

Use attributes of EditText android:enabled="false" and in your button event handler use ((EditText)findViewById(R.id.edittext)).setEnabled(true); if id of EditText is edittext.