AndreiBogdan
AndreiBogdan

Reputation: 11164

Android check editable value for EditText object

How can you get and set the editable value (true/false) of a EditText object?

Upvotes: 0

Views: 983

Answers (4)

Vit Khudenko
Vit Khudenko

Reputation: 28418

In Android EditText does not operate with "editable" concept. Instead, in addition to "focusable"/"non-focusable", it can be "enabled"/"disabled":

boolean EditText.isEnabled()
void EditText.setEnabled(boolean enabled)

Upvotes: 1

JWL
JWL

Reputation: 14201

Try this (but there might be a better approach):

To prevent someone editing content in the EditText:

EditText comment = (EditText)findViewById(R.id.txt_comment);
comment.setEnabled(false);

make it editable:

comment.setEnabled(true);

Then to check whether it's editable:

comment.isEnabled()

Upvotes: 2

Mun0n
Mun0n

Reputation: 4437

An EditText is always editable. There is no way to get the editable value from a EditText.

Upvotes: 1

Boris Strandjev
Boris Strandjev

Reputation: 46943

This is combination of the properties getFocusable and getEnabled, though in some cases it might be that just getEnabled can do the trick for you.

Upvotes: 1

Related Questions