我的键盘有问题。我研究了所有的“Stackoverflow”,测试了数百万种不同的方法。当“对话框”出现时,仍然无法隐藏键盘。可能有人有 10000% 的工作解决方案吗?
public class ConfirmDialog extends DialogPreference implements OnClickListener{
public ConfirmDialog(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
setPositiveButtonText(R.string.b_ok);
setNegativeButtonText(R.string.b_cancel);
}
protected View onCreateDialogView(){
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View createdv = inflater.inflate(R.layout.confirm_dialog, null);
//Here I've tried to hide a keyboard!!!!!!!!!!!!!!
((EditText) createdv.findViewById(R.id.confirm_name)).setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if(hasFocus)
{
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}
// TODO Auto-generated method stub
}
});
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);}
}