title: Android Studio listview, intent
body: <p>I am making a pretty simple app which displays 100 random numbers, and when a number is clicked in the list view, it launches a web browser. I am pretty sure I have everything done and working, but is there anyway to tie the same intent to each number/position in the list? Besides a switch statement? I will do a switch statement if needed, but 100 numbers is a lot. Haha. For the life of me I cannot figure out what to do. Would a loop work? I have only been using Android Studio for about two months.Thanks in advance for all your help.</p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id){
  
      switch ( position ) {
          case 0: String link = "https://duckduckgo.com/";
              Uri uri = Uri.parse(link);
              Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
              startActivity(viewIntent);
      }
  
      String link = "https://duckduckgo.com/";
      Uri uri = Uri.parse(link);
  
  
      Intent viewIntent = new Intent(Intent.ACTION_VIEW, uri);
      startActivity(viewIntent);
  }
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_assignment4);
  
      ListView ListViewNumbers = (ListView) findViewById(R.id.ListViewNumbers);
  
  
      Random ran = new Random();
      List&lt;Integer&gt; nums = new ArrayList&lt;&gt;(100);
          for(int i = 0; i &lt; 100; i++){
              Integer r = ran.nextInt();
              nums.add(r);
          }
  
      ArrayAdapter&lt;Integer&gt; adapter = new ArrayAdapter&lt;Integer&gt;(this, R.layout.num_list_layout, nums);
      ListViewNumbers.setAdapter(adapter);
  
  
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_assignment4, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  </code></pre>
  
  <p>}</p>