开发者

How to override the long key press functionality in android?

can anyone tell me how can we overide the long key press functionalty of menu key? I have to call an activity on long press on m开发者_开发知识库enu key for device samsung galaxy S. Please tell me how can implement that...some sample code is appreciable.


Try with the following code

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
    // TODO Auto-generated method stub

       if(keyCode == KeyEvent.KEYCODE_MENU){
           System.out.println("......menu is clicked...");
       }
    return super.onKeyLongPress(keyCode, event);

}


override onLongKeyPress() method...

@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {


       if(keyCode == KeyEvent.KEYCODE_MENU){
           //your stuff
       }
    return true;
//you should return true at last
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜