title: Getting rid of lengthy switch statement in favor of a loop or other conditional statement?
body: <p>Alright, so I asked a question like this a long while ago, but I didn't quite get the answer I was looking for. Mainly probably because I didn't include enough code. I'll paste it first then explain after.</p>
  
  <pre><code>public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
      super.onCreateContextMenu(menu, v, menuInfo);
      menu.setHeaderTitle("Save as...");
      menu.add(0, v.getId(), 0, "Ringtone/Notification");
  }
  
  @Override
  public boolean onContextItemSelected(MenuItem item) {
      if (item.getTitle() == "Ringtone/Notification") {
          function1(item.getItemId());
      } else {
          return false;
      }
      return true;
  }
  
  // detect button clicked, save as a ringtone using strings.xml
  public boolean function1(int ressound) {
  
      String soundname = "";
  
  
      switch (ressound) {
          case R.id.button01:
              ressound = R.raw.sound01;
              soundname = (this.getString(R.string.app_name)) + " - " + (this.getString(R.string.quote01));
              break;
          case R.id.button02:
              ressound = R.raw.sound02;
              soundname = (this.getString(R.string.app_name)) + " - " + (this.getString(R.string.quote02));
              break;
          case R.id.button03:
              ressound = R.raw.sound03;
              soundname = (this.getString(R.string.app_name)) + " - " + (this.getString(R.string.quote03));
              break;
      }
  </code></pre>
  
  <p>My problem lies with the switch statement. Eventually, there are going to be a LOT of buttons/quotes/sounds that all match by the numbers after "button" "sound" and "quote". In my last app, it got very, very tedious and tiresome to go through and copy/paste up to 50 switch cases at a time and go through and edit each one to be specific to button10/sound10/quote10, button11/sound11/quote11, etc.</p>
  
  <p>I've tried to play around with some stuff, but can't seem to get it to work.</p>
  
  <p>If it helps, I have them all in arrays like this (for a purpose currently elsewhere in the code):</p>
  
  <pre><code>final int[] buttonIds = {R.id.button01, R.id.button02, R.id.button03,
          R.id.button04, R.id.button05, R.id.button06,
          R.id.button07, R.id.button08, R.id.button09,
          R.id.button10};
  
  final int[] soundIds = {R.raw.sound01, R.raw.sound02, R.raw.sound03,
          R.raw.sound04, R.raw.sound05, R.raw.sound06,
          R.raw.sound07, R.raw.sound08, R.raw.sound09,
          R.raw.sound10};
  
  final int[] stringIds = {R.string.quote01, R.string.quote02, R.string.quote03,
          R.string.quote04, R.string.quote05, R.string.quote06,
          R.string.quote07, R.string.quote08, R.string.quote09,
          R.string.quote10};
  </code></pre>
  
  <p>Thank you in advanced for your help and guidance!</p>