title: OnItemClickListener that can have more or less items
body: <p>I have a server with a database. In my database I have 25 items at the moment but will be adding items and removing them. </p>
  
  <p>I have the <code>ListView</code> in java working for the 25 items by simply writing a switch n case method. </p>
  
  <p>But how could I write it so that as items in my data base are added or removed it adds the extra case items to my on <code>ItemListener</code>.</p>
  
  <p>This is how I have it at the moment but I don't want to update my app every time I add a new item </p>
  
  <pre><code>lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                  @Override
                  public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                      switch(i){
                          case 0:
                              break;
                      }
                  }
              });
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>this is how i add the items to the list using firebase</p>
  
  <pre><code>mrootref = new Firebase("my firebaselink");
  lv = (ListView)findViewById(R.id.lvnames);
  
  mrootref.child("Mydatabase name").addChildEventListener(new ChildEventListener() {
  
      @Override
      public void onChildAdded(DataSnapshot snapshot, String s) {
          final ArrayAdapter&lt;String&gt; jlistAdapter = new ArrayAdapter&lt;String&gt;(MainActivity.this,android.R.layout.simple_list_item_1, webstreamsArray);
          lv.setAdapter(jlistAdapter);
  
          String streamname = snapshot.child("name").getValue(String.class);
          jlistAdapter.notifyDataSetChanged();
          webstreamsArray.add(streamname);
          lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
              @Override
              public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
                  switch(i){
                      case 0:
                          break;
                  }
              }
          });
      }
  }
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>below ive included a screenshot of my database structure. my app then calls the name part of the database and populates them to my listview. if an item is deleted it removes the item from my listview. i want to use the "url" item so that when the name item is clicked it opens the url item</p>
  
  <p><a href="https://i.stack.imgur.com/q9EEc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q9EEc.png" alt="enter image description here"></a></p>