문제

I have a problem with the keyboard. I've research all the "Stackoverflow", I've tested million of different methods. And still cannot to make the keyboard hidden, when the "Dialog" shows up. May be anybody has a 10000% working solution?

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);}

}

도움이 되었습니까?

해결책

Solved… In XML document right in front of EditText tag I've added…

<LinearLayout android:focusable="true"
            android:focusableInTouchMode="true" 
            android:layout_width="0px"
            android:layout_height="0px" />

I've read it here.

다른 팁

this how i implement it in my project this method take the view like edittext and hide the soft keyboard

private void hidesoftKeyboard(View v) {

    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(v.getWindowToken(), 0);

}

feed me back

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top