Timer timer = new Timer();
timer.schedule(new TimerTask()
{
public void run()
{
InputMethodManager inputManager =(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
}, 998);
这是java ** 我想延迟键盘弹出**
答案 0 :(得分:0)
public class MyActivity: IRunnable{
Android.OS.Handler _handler;
protected void MethodXY(){
_handler = new Android.OS.Handler();
_handler.PostDelayed(this, 998);
}
public void Run()
{
_handler.RemoveCallbacks(this);
InputMethodManager inputManager =(InputMethodManager)editText.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(editText, 0);
}
}
替代方案:(例如,您在活动中使用多个处理程序)
public class MyActivity: IRunnable{
protected void MethodXY(){
Android.OS.Handler handler = new Android.OS.Handler();
handler.PostDelayed(new DelayedKeyboardRunnable(handler, editText), 998);
}
private class DelayedKeyboardRunnable: Java.Lang.Object, IRunnable
{
EditText _et;
Android.OS.Handler _handler;
public DelayedKeyboardRunnable(Android.OS.Handler handler, EditText et)
{
_handler = handler;
_et = et;
}
public void Run()
{
_handler.RemoveCallbacks(this);
InputMethodManager inputManager = (InputMethodManager)_et.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
inputManager.showSoftInput(_et, 0);
}
}
}