balaji
balaji

Reputation: 1575

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 }

Upvotes: 1

Views: 171

Answers (2)

Michel-F. Portzert
Michel-F. Portzert

Reputation: 1785

Your code seems correct (apart from the synthax error), the only difference I see from working examples is your event.getAction() condition. I'd suggest to check the ACTION_DOWN clause.

Upvotes: 1

Shekhar Chikara
Shekhar Chikara

Reputation: 3822

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

Upvotes: 2

Related Questions