How to know how long the key is pressed?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

How to know how long the key is pressed?

Postby patrickzheng » Sat Jun 13, 2009 6:14 pm

here is my code

public boolean onKeyUp(int keyCode, KeyEvent event)
{ Message m = new Message();
m.what = theGamev2.REDRAW;

switch(keyCode)
{ case KeyEvent.KEYCODE_DPAD_CENTER:
releaseTime = System.currentTimeMillis();
this.mBall.createNewCircle(pointerCurrentXCoord, 30, ((int)
(releaseTime - pressTime))/10);
break;
default:
return super.onKeyDown(keyCode, event);
}


this.mBallUpdateHandler.sendMessage(m);
return true;
}

public boolean onKeyDown(int keyCode, KeyEvent event) {
Message m = new Message();
m.what = theGamev2.POINTER;

switch(keyCode){
case KeyEvent.KEYCODE_DPAD_CENTER:
pressTime = System.currentTimeMillis();
break;
default:
return super.onKeyDown(keyCode, event);
}

this.mBallUpdateHandler.sendMessage(m);
return true;
}




i am using system time here to get the difference....but it doesnt work like the way i want..
i wonder is there method or concept to know how long the key is pressed??
Please give me an example if u have a way to do it...Thanks a lot.
patrickzheng
Once Poster
Once Poster
 
Posts: 1
Joined: Sat Jun 13, 2009 6:07 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 11 guests