如何处理来自手机键盘数字键 [英] how to handle numeric keys from the phone keypad

查看:218
本文介绍了如何处理来自手机键盘数字键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的键盘:

In following keypad:

我们可以选择由pressing按键值的(如查看button1.setOnClickListener(..))的所有我想知道的是如何处理键(按键0到9,enter_key在其他设备上运行,则平板电脑时,从手机按键(如clear_key))。

we can select value by pressing buttons (e.g View button1.setOnClickListener(..)), all i want to know is how can i handle keys(keys 0 to 9, enter_key, clear_key) from the phone keypad (e.g. when running on device other then tablet).

请给一个快速REFFERENCE。任何网上的教程将是非常有益的。

Please give a quick refference. any online tutorial will be highly helpfull.

问候,

推荐答案

您可以去的onkeydown这需要关键code和KeyEvent的作为参数,并KeyEvent的类包含了所有的数字codeS:

you can go for onKeyDown which takes keycode and KeyEvent as arguments and KeyEvent class contains all the numeric codes:

    public boolean onKeyDown(int keyCode, KeyEvent event) {
           if(keyCode==KeyEvent.KEYCODE_0){
           //do some stuffs           
           }else if(keyCode==KeyEvent.KEYCODE_1) {
          // do some stuffs
           }
            return super.onKeyDown(keyCode, event);
        }

这样你可以处理的数字键preSS /。希望它西港岛线帮助你。 :)

Like this you can handle numeric key press/.Hope it wil help you. :)

这篇关于如何处理来自手机键盘数字键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆