我有一个 TableLayout,我在 OnCreate 的代码中动态添加内容。一旦 Activity 创建,它就会专注于我动态创建的 EditText 之一并显示键盘。在用户专门按下 EditText 之一之前,我不希望键盘显示。我试过了:
InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
但是键盘仍然显示并且 CurrentFocus 返回 null。因此,当我尝试将焦点专门指向另一个视图然后执行上述操作时:
InputMethodManager input = (InputMethodManager) GetSystemService(InputMethodService);
title.FindFocus();
input.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
CurrentFocus 仍然为空,键盘仍然显示。title 是一个 TextView,我已经在代码中有一个实例。我可以不把焦点放在 TextView 上还是我还缺少其他东西?