开发者

Displaying Soft Keypad Via Code

开发者 https://www.devze.com 2023-02-15 09:20 出处:网络
How could I keep the keypad visible, or display the keypad for the next EditText views via.I would like to keep the keypad visible if the input is invalid.Or, in the case of valid input, display the k

How could I keep the keypad visible, or display the keypad for the next EditText views via. I would like to keep the keypad visible if the input is invalid. Or, in the case of valid input, display the keypad after requesting focus on the next EditText.

My validation:

private boolean processTextField( EditText str ) {

        Log.v( "Exfo. Processing: ", str.getText().toString() );

        boolean notZero = ( (str.getText().toSt开发者_StackOverflow社区ring().length() > 0) &&  (this.notZero(str.getText().toString())) ); // checks id value is zero

        if ( notZero ) {
            if ( this.frameSizeLength() == 0 ) {
                txtFrameSize.requestFocus();
                // TO DO:  display keyboard
            }
            else if ( this.thruPutLength() == 0 ) {
                txtThruPut.requestFocus();
                // TO DO:  display keyboard
            }
            else
                    this.calcResults(Integer.valueOf(txtFrameSize.getText().toString()), Float.valueOf(txtThruPut.getText().toString()) );
            }
            else {
                this.showMSG("Enter a value greater than zero.");
                // TO DO:  keep focus on current EditTExt, display keypad
            }
    }
}

EDIT: There are only 2 EditText views: framesize and thruput.

Right now, no matter what, the keypad is hidden after hitting the return/done button. I am targeting Android 2.2, but I focusing on touch only devices for now. Thanks, MD


You can use this to force it open on a specified View.

InputMethodManager imm = (InputMethodManager) getSystemService(
    Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(editText, InputMethodManager.SHOW_FORCED);
0

精彩评论

暂无评论...
验证码 换一张
取 消