How to disable the keys of the phone programmatically during runtime
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
精彩评论