C# arrow key input for a console app

A bit late now, but here’s how to access keyboard state in a console application. Note that it’s not all managed code as it requires GetKeyState to be imported from User32.dll. /// <summary> /// Codes representing keyboard keys. /// </summary> /// <remarks> /// Key code documentation: /// http://msdn.microsoft.com/en-us/library/dd375731%28v=VS.85%29.aspx /// </remarks> internal enum KeyCode : int … Read more

How to use View.OnTouchListener instead of onClick

The event when user releases his finger is MotionEvent.ACTION_UP. I’m not aware if there are any guidelines which prohibit using View.OnTouchListener instead of onClick(), most probably it depends of situation. Here’s a sample code: imageButton.setOnTouchListener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(event.getAction() == MotionEvent.ACTION_UP){ // Do what you want return true; … Read more