views:

35

answers:

1

I use the following code to pop up the soft input keyboard in my Activity


InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.getInputMethodList();

imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);

This displays the alphabetic keyboard.

But I want to display the numeric keyboard.

Please note I know that using setInputType() works when used with an Edittext or a TextView but I want to be able to display the keyboard without an input area such as an EditText and simply listen to the key presses on the keyboard.

Can anyone confirm whether this is possible and if so how can it be achieved?

+1  A: 

try using the "onKeyDown" methods, I use them for capturing the "back" hard key on phones in my application, an example of the method, using back as the button its listening for, would be

    public boolean onKeyDown(int keyCode, KeyEvent event){
      if((keyCode == KeyEvent.KEY_BACK)){
          back();
      }
         return super.onKeyDown(keyCode,event);
   }

But instead of using KeyEvent.KEY_BACK, try using KeyEvent.KEYCODE_P instead. I'm not possitive if this will work on a soft keyboard, but its worth a shot! good luck

Samuel
Hi Samuel, sorry I should have been more clear, I can successfully capture the keys but my issus is that the keyboard is aphabetical and I want it to pop up as numeric
Donal Rafferty
alright, to further help, can you tell me exactlly what elements you are using on your xml? or whats being accomplished here?
Samuel