嗨,我正在尝试输入这段代码来隐藏 android 上的软键盘,但它返回一个空指针。
代码:
public void testSetTestEnvironment (){
solo.clickInList(4);
solo.clickOnMenuItem(ConfigVariables.CATALOGSERVER);
assertTrue(solo.searchText(ConfigVariables.CATALOGSERVERURL));
//Enter KeyCode
solo.clickInList(5);
View myEditText = solo.getViews().get(0);
InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), InputMethodManager.HIDE_IMPLICIT_ONLY);
solo.enterText(solo.getEditText(0), "");
solo.enterText(0, ConfigVariables.KEYCODE);
assertTrue(popupClickButtonHandler("Enter KeyCode", "OK"));
日志显示:
java.lang.NullPointerException
谢谢。