我在Android中有一个 Activity
,有两个元素:
EditText
ListView
当我的 Activity
启动时, EditText
立即具有输入焦点(闪烁的光标)。我不希望任何控件在启动时具有输入焦点。我试过了:
EditText.setSelected(false);
EditText.setFocusable(false);
没运气。我如何说服 EditText
在 Activity
启动时不选择自己?
原文由 Mark 发布,翻译遵循 CC BY-SA 4.0 许可协议
Adding the tags
android:focusableInTouchMode="true"
andandroid:focusable="true"
to the parent layout (egLinearLayout
orConstraintLayout
) like in the following example, will fix the problem .