I found that there is a some problem to do EdiText component not editable from code. Yes,it is very easy to do that from layout xml file. There you can use tag android:editable which allows to set will this component editable or not.
EditText component hasn’t method setEditable. There is other approach,need to use InputFilter.
I am going to show how you can make your EditText not editable from code using InputFilter.
It is very easy. You need only set filter for your EdiText component.
editText.setFilters(new InputFilter[]{new InputFilter(){@Overridepublic CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){return source.length() < 1 ? dest.subSequence(dstart,dend):""}} });As you see we set filter for our EditText object and we override method filter. Now our EditText component is not editable.
I also want to show here full example:
import android.app.Activity;import android.os.Bundle;import android.text.InputFilter;import android.text.Spanned;import android.view.View;import android.widget.Button;import android.widget.EditText;public class Main extends Activity{private EditText editText;private boolean value = false;@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);editText = (EditText) findViewById(R.id.textId);editText.setText("EditText component");Button b = (Button) findViewById(R.id.btnId);b.setText("Lock/Unlock");b.setOnClickListener(new View.OnClickListener(){@Overridepublic void onClick(View v){if (value){value = false} else{value = true}lockUnlock(value)}})}private void lockUnlock(boolean value){if (value){editText.setFilters(new InputFilter[]{new InputFilter(){@Overridepublic CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){return source.length() < 1 ? dest.subSequence(dstart,dend):""}} })} else{editText.setFilters(new InputFilter[]{new InputFilter(){@Overridepublic CharSequence filter(CharSequence source,int start,int end,Spanned dest,int dstart,int dend){return null}} })}}}Also simple layout file main.xml:
In this example I make EditText component editable and not editable.
If you need to make EditText component editable just return null from filter method.
As you see this procedure is simple.
I hope that this post is useful for you.
Leave a comment.
No related posts.

Awesome,thanks!
That was just what I was looking for. Thank you sooooo much!
Cheers
Drew