Home > Articles > Web Services > XML

  • Print
  • + Share This
Like this article? We recommend

Selecting a Tune

RTTTL tunes are listed on the RTTTLEx screen and played using the class RTTTLExCanvas. When the user selects a tune from the List object in RTTTLEx using the cell phone's up- and down-arrow buttons, and then presses the Play button, the Command object playCommand is trapped in RTTTLEx's commandAction() method, as shown in Listing 7:

Listing 7 Processing Commands in the RTTTLEx Class

public void commandAction(Command c, Displayable s) {
    if (c == exitCommand) {
    }else if ((s == theList &&
          c == List.SELECT_COMMAND) ||
          c == playCommand) {
      //Find out which tune has been selected
      int i = theList.getSelectedIndex();
      //Let the tune player, RTTTLExCanvas, know which
      //tune has been selected
      //Attach the player as the current
      //UI display
      //do all necessary screen redrawing
      //play the tune!

The actual work of getting the RTTTL file from the Internet and playing it is encapsulated in the class RTTTLExCanvas.

  • + Share This
  • 🔖 Save To Your Account