We can set editable property of EditText in XML layout but not programatically, but there is no setEditable() method!
If EditText is not Enabled [ by setEnabled(false)] it still Editable!
We can set editable property of EditText in XML layout but not programatically, but there is no setEditable() method!
If EditText is not Enabled [ by setEnabled(false)] it still Editable!
try this,
EditText editText=(EditText)findViewById(R.id.editText1);
editText.setKeyListener(null);
It works fine...
Since the setEditable(false) is deprecated and we can't use it programmatically, we can use another way to solve it with setInputType(InputType.TYPE_NULL)
It means we change the input type of edit text. We set it to NULL so it becomes not editable.
Here's the sample that might be useful (I code this on my onCreateView method Fragment):
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.yourfragment, container, false);
EditText sample = view.findViewById(R.id.youredittext);
sample.setInputType(InputType.TYPE_NULL);
Hope this will answer the problem