禁用线性布局内的所有edittext [英] Disable all edittext inside linear layout
本文介绍了禁用线性布局内的所有edittext的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试禁用线性布局内的所有字段.该线性布局中有许多edittext和textview.但是,我只是想禁用edittext.我能够禁用所有子项,但我希望能够禁用编辑文本.有什么办法吗?
I am trying to disable all field inside linear layout. There are many edittext and textview inside that linear layout. However, i am only trying to disable edittext. I was able to disable all children but i want able to disable on edit text. Is there any way to do that?
推荐答案
其中 ll
是您的线性布局:
LinearLayout ll = (LinearLayout) findViewById(R.id.myLLid);
for (View view : ll.getTouchables()){
if (view instanceof EditText){
EditText editText = (EditText) view;
editText.setEnabled(false);
editText.setFocusable(false);
editText.setFocusableInTouchMode(false);
}
}
这篇关于禁用线性布局内的所有edittext的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文