小编Dev*_*Dev的帖子

无法解析片段类中的方法getsystemservice

我如何在片段类中使用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);
Run Code Online (Sandbox Code Playgroud)

java android

0
推荐指数
1
解决办法
1666
查看次数

标签 统计

android ×1

java ×1