Search code examples
androidkeyevententer

how to use Enter on softkeyboard for my app?


I have big problem with my keyevent i am trying to call my another acvitity but the keyevent is not working please check what mistake i made for my code. actually i created one carousel design if i press softkeyboard enter button in my laptop the keyevent is not working...

This case is not working for me...

case KeyEvent.KEYCODE_ENTER:
                System.out.println("enter pressed");
            if(position==0);{
                Intent intent = new Intent(sampleActivity.this, test.class);
                startActivity(intent);

enter image description here }


Solution

  • I suppose you need to enable your keyboard input. Even though the developer documentation says keyboard support is enabled by default it doesn't seem to be that way in SDK rev 20. I explicitly enabled keyboard support in my emulator's config.ini file and that worked!

    Add: hw.keyboard=yes

    To: ~/.android/avd/.avd/config.ini

    Reference: http://developer.android.com/tools/devices/managing-avds-cmdline.html#hardwareopts