title: How to select random values from a given range
body: <p>I'm trying to create an android application which will generate random series of values (integer numbers in this case) in a given range (but <strong>NOT</strong> equal between them) and display them in a simple TextView</p>
  
  <p>Let's say we have the range <strong>R = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]</strong></p>
  
  <p>Each time I press the button <strong><em>"Generate"</em></strong> I want to randomly generate  5 different results </p>
  
  <p><strong>Example for each "Generate":</strong></p>
  
  <ul>
  <li>4, 9, 2, 12, 10</li>
  <li>5, 1, 6, 8, 13</li>
  <li>10, 4, 6, 8, 2</li>
  <li>etc...</li>
  </ul>
  
  <p><strong>EDIT (works now) Thanks for all the help!</strong></p>
  
  <pre><code>public class random extends Activity {
  
  
  static final Integer[] data = new Integer[] {
      1, 2, 3, 4, 5, 6, 7, 8
      };
  
  
  @Override
  public void onCreate(Bundle icicle) {
      super.onCreate(icicle);
      setContentView(R.layout.main);
  
      Random r = new Random();
  
      Set&lt;Integer&gt; mySet = new HashSet&lt;Integer&gt;();
      while (mySet.size() &lt; 5) {
         int idx = r.nextInt(data.length);
         mySet.add(data[idx]);
      }
  
      String text = "";
      for (Integer i : mySet) {
         text = text + i + ", "; 
      }
         TextView Numbers = (TextView)findViewById(R.id.shownumbers);
         Numbers.setText(text);
    }
  }
  </code></pre>