-1
我如何使用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);
嘗試getActivity()。getSystemService – Pavya
非常感謝普拉它工作得很好,現在 – DevDev
@DevDev不要忘記給予正確的回答或有利的評論。建議參觀Stackoverflow。 –