我是项目中的 android 新手,我可以选择在数据库中搜索记录。当用户按下按钮时,我有一个 EditText 和一个 Button 数据库将被查询用户在 EditText 中输入的文本。
显示搜索结果后第一次正常工作。为了更改搜索文本,用户希望在出现的 EditText 软键盘中编辑文本,但 EditText 对用户操作和软键盘输入没有响应。
EditText 作为标题添加到 ListView
searchstringsearch=(EditText)searchview_headerview.findViewById(R.id.searchstringsearch);
searchstringsearch.setTypeface(SharedVariables.font);
searchstringsearch.setFilters(BLCOobj.setFilters("filterForSearchString"));
searchstringsearch.setOnEditorActionListener(new DoneOnEditorActionListener());
class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
/*InputMethodManager imm = (InputMethodManager) getSystemService(HomeScreen.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(searchstringsearch.getWindowToken(), 0);*/
hideKeyboard();
String SearchOption=searchstringsearch.getText().toString();
if(SearchOption!=null)
{
if(SearchOption.length()>=4)
{
BLHomeScreenOperations objBLHomeScreenOperations=new BLHomeScreenOperations();
clsSearch objSearch=new clsSearch(objdatasetslist.get(dataSetIndex).getDataSetID(),SearchOption );
//callig getSearchResults In BL
objBLHomeScreenOperations.getSearchResults(objSearch, HomeScreen.this);
}else{
SharedVariables.showAlertMessage(SharedVariables.globalContext.getString(R.string.enter_searchstring_msg), HomeScreen.this);
}
}else{
SharedVariables.showAlertMessage(SharedVariables.globalContext.getString(R.string.enter_searchstring_msg), HomeScreen.this);
}
return true;
}
return false;
}
}
当用户第二次单击进行编辑时,EditText 日志显示以下消息
V/InputMethodManager(16958): Starting input: tba=android.view.inputmethod.EditorInfo@420ef980 ic=null