简体   繁体   中英

Android Studio Soft Keyboard Close

I am using the soft keyboard in Android Studio in order to display user input on the screen. The program has a button, that when clicked, displays whatever it is that the person typed in. As soon as I click on the EditText field, the soft keyboard pops up and I type in the input. The only problem is that I dont know how to close it after I'm done. My Textfield, which displays the input, is at the bottom of the screen so I can't see it if the keyboard remains open. Shouldn't there be some type of button? Is there a way of solving this??? Thank you.

软键盘不输入

in the OnClickListener of the button, which you are using to display the text entered when clicked, you can add some thing which closes the keyboard when clicked. Add this inside the onClickListener

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

so when you click the button, it hides the keyboard and displays the text entered.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM