android 朋友圈评论输入框显示隐藏获得焦点弹出软键盘

2025-03-22 21:15:42
推荐回答(1个)
回答1:

当editText获取焦点的时候,需要直接调用显示键盘命令:
editText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
  @Override
  public void onFocusChange(View v, boolean hasFocus) {
  if (hasFocus) {
  dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  
   }
   }
  });