im displaying web page content in webview and i want to di开发者_运维百科sable the all 4 arrow key of android keyboard. any idea?
edit:
public boolean onKeyDown(int keyCode, KeyEvent event) {
int a;
Log.d("yourTag",""+event.getAction());
System.out.println(a=event.getAction());
System.out.println(keyCode);
if(event.getAction()==20){
return true;
}
else if(event.getAction()==21){
return true;
}
else if(event.getAction()==22){
return true;
}
else{
return true;
}
}
scrolling still there but back key and menu key is disabled why? i noticed it returns nothing if content is scrolling. once scrolling ends it(log.d message) returns 0.
You can catch them in an onkeydown?
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == /*INSERT YOUR KEY*/){
//do something with the arrows. or ignore them
//return true or false depending on if you want to "catch" the event i guess
}else{
return super.onKeyDown(keyCode, event);
}
}
You'd only have to find the code for the arrow-keys, that shouldn't be to hard. You could even just Log.d your event.getAction()
, and press them, to find out what they're called...
I don't really know what you are doing with your debugcode, but check out this link: http://developer.android.com/reference/android/view/KeyEvent.html for the key events. The events are integers. Why don't you add this for debugging:
public boolean onKeyDown(int keyCode, KeyEvent event) {
Log.d("yourTag",""+event.getAction());
}
and see what's returned? My guess would be one of the DPAD keys, for instance left ( 21 ) are your target
精彩评论