gpt4 book ai didi

android - 在android中隐藏键盘

转载 作者:行者123 更新时间:2023-11-29 21:47:00 25 4
gpt4 key购买 nike

我使用以下代码作为 util 文件方法来在我单击按钮时隐藏我的键盘。

public static void hideKeyPad(){
Activity activity = MainActivity.getActivity();
InputMethodManager imm = (InputMethodManager) activity.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}

但是小键盘一直都在。请指正。

最佳答案

尝试使用这段对我有用的代码

 InputMethodManager inputManager = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_IMPLICIT_ONLY);

关于android - 在android中隐藏键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15518077/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com