title: Android How to hide and display items in a ListView when a ListView item is clicked
body: <p>Hey i'm using and android ListView I want to display some items while adding others in the same ListView when i click on a ListView item. what i mean is when i click on one item some images are displayed on the same row. when i click on another item the previous images disappear while I'm left with the ones in the new row please help here is my code</p>
  
  <pre><code>inventoryList.setAdapter(mAdapter);
      inventoryList.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2,
                  long arg3) {
              // TODO Auto-generated method stub                  
              LinearLayout lButtons;
  
              // Hides all items in the listView adapter  
              for (int i = 0; i &lt; inventoryList.getAdapter().getCount(); i++) {
  
  
                     View v1 = inventoryList.getChildAt(i);  
                     lButtons = (LinearLayout) v1.findViewById(R.id.layout_update_buttons);
                     lButtons.setVisibility(View.GONE);
  
  
              }
  
              //Display images of currently clicked item
              lButtons = (LinearLayout) arg1.findViewById(R.id.layout_update_buttons);
              lButtons.setVisibility(View.VISIBLE);
  
          }
  
      });
  </code></pre>
  
  <p>it currently gives me a java.lang.nullPointerException in this particular line</p>
  
  <pre><code>lButtons = (LinearLayout) v1.findViewById(R.id.layout_update_buttons);
  </code></pre>