2017-02-22 64 views
0

我有一個關於在Android鍵盤引導「號」輸入型問題。引導手機數字鍵盤 - 輸入事件

我只想在移動鍵盤上顯示數字。所以,我在輸入上使用「數量」型。但數字鍵盤在Android中,「下一頁」按鍵不會引發像普通鍵盤「下一步」按鈕「進入」事件。

反正有數字鍵盤/輸入觸發「Enter」事件嗎?

+0

後你已經嘗試的代碼。沒有人會讀心術這裏我不認爲 – mlegg

回答

0

從我所瞭解的情況來看,當數字鍵盤上的輸入/完成鍵被擊中時,需要執行「某些」操作。

下面是我之前在其中一個應用中使用的代碼片段,當用戶點擊完成/輸入鍵時,輸入被點擊並執行操作時顯示數字鍵盤。

  • 在您所擁有的輸入字段中添加setOnEditorActionListener。
  • 覆蓋的onEditorAction方法,並檢查actionId == IME_ACTION_DONE

     
        //Using the set edit listener to handle the events that occur when the Done/Search key is pressed 
        userInput.setOnEditorActionListener(new TextView.OnEditorActionListener() { 
         @Override 
         public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 
          //When the search/done key is pressed 
          if (actionId == EditorInfo.IME_ACTION_DONE) { 
    // Do your action when Enter Key pressed 
    }