Home > Articles > Mobile Application Development & Programming

  • Print
  • + Share This
From the author of Design for No Buttons

Design for No Buttons

A tablet experience is different from a phone, and it already seems many models will have only one or even no physical buttons. Therefore, apps should be designed for easy navigation without a BACK key or MENU key.

One method is to utilize multi-touch more. With a larger screen, an event with two or more fingers down is natural. Such an event can be identified by implementing the OnTouchListener class and overriding the onTouch() method to classify the touch event. This is shown in the following example:

      public boolean onTouch(View v, MotionEvent event) {
            final int action = event.getAction();
            switch (action & MotionEvent.ACTION_MASK) {
            case MotionEvent.ACTION_DOWN:
                  //primary touch event starts (first finger)
                  //log location
                  fingerX[0] = event.getX(0);
                  fingerY[0] = event.getY(0);
                  
                  case MotionEvent.ACTION_POINTER_DOWN:
                  //a non-primary touch event starts (added finger)
                  //log location
                  final int pointerIdx = 
                      (action & MotionEvent.ACTION_POINTER_INDEX_MASK) 
                        >> MotionEvent.ACTION_POINTER_INDEX_SHIFT;
                  fingerX[pointerIdx] = event.getX(pointerIdx);
            fingerY[pointerIdx] = event.getY(pointerIdx);			
            }
            return true;
      }

In addition, the ACTION_MOVE event can be accessed to detect the movement of a pointer [ 2 ]. By detecting multiple finger presses and movements, a rich set of features can be accessed. For example, two-finger drag can provide a different result from one-finger drag.

  • + Share This
  • 🔖 Save To Your Account