gpt4 book ai didi

java - 无法解析 fragment 类中的方法 getsystemservice

转载 作者:行者123 更新时间:2023-12-05 00:10:01 24 4
gpt4 key购买 nike

我怎样才能像下面的代码那样在 fragment 类中使用 getSystemService

final EditText input = new EditText(getContext());
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(input, InputMethodManager.SHOW_IMPLICIT);
// Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_TEXT);
//Show Automatic KeyBoard
input.postDelayed(new Runnable() {
@Override
public void run() {
InputMethodManager keyboard = (InputMethodManager) getBaseContext()
.getSystemService(Context.INPUT_METHOD_SERVICE);
keyboard.showSoftInput(input, 0);
}
}, 50);
builder.setView(input);

最佳答案

使用
getActivity().getSystemService

关于java - 无法解析 fragment 类中的方法 getsystemservice,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43848399/

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