0
  1. 单击添加按钮(插入的数据)到数据库后,如何自动清除文本框?
  2. 如何将键盘上的 DONE 按钮(用户想要键入时提示)链接到我的 ADD 按钮?
4

1 回答 1

1

您需要使用 OnEditorActionListener,在其中单击按钮、隐藏键盘并将文本设置为“”。像这样:

   mEditText.setOnEditorActionListener(new OnEditorActionListener(){
        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            mButton.performClick();
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
            v.setText("");
            return true;
        }
});
于 2012-05-15T20:19:34.530 回答