开发者

How to disable the keys of the phone programmatically during runtime

开发者 https://www.devze.com 2023-03-11 21:42 出处:网络
Inside my Jumbled words game app, I want a way such that only the alphabet keys of the keyboard are enabled, depending on the scrambled words appearing. For example, \"rrowa\" is a scrambled form of t

Inside my Jumbled words game app, I want a way such that only the alphabet keys of the keyboard are enabled, depending on the scrambled words appearing. For example, "rrowa" is a scrambled form of the word "arrow" and only the keys 'a', 'r', 'o', 'w' must be enabled and the remaining keys must be disabled. When a next scrambled 开发者_开发问答word appears for examples "nife" which is a scrambled form of "fine", only alphabets 'f', 'i', 'n', 'e' must be enabled. How do we do this?


You need to do something like this:

 public boolean onKeyDown(int keyCode, KeyEvent event) {

        if (keyCode == "your key") {
            return true;

        }else return super.onKeyDown(keyCode, event);
   }

You need to find out the key code using Key Event

0

精彩评论

暂无评论...
验证码 换一张
取 消