2012-05-15 22 views
0
  1. 如何在點擊添加按鈕(插入數據)到數據庫後自動清除文本框?
  2. 如何將鍵盤上的DONE按鈕(用戶想輸入時提示)鏈接到我的ADD按鈕?

回答

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; 
     } 
});