title: Visibility GONE in ListView
body: <p>I use a <code>ListView</code> to display <code>TextViews</code>. My app looks like this:</p>
  
  <p><img src="https://i.stack.imgur.com/dG7l2.png" alt="enter image description here"></p>
  
  <p>When I click on a word it disappears:</p>
  
  <p><img src="https://i.stack.imgur.com/QY6IO.png" alt="enter image description here"></p>
  
  <p>But the <code>ListView</code> still keeps the empty row. I want my app to look like this after click:</p>
  
  <p><img src="https://i.stack.imgur.com/MBIsR.png" alt="enter image description here"></p>
  
  <p>Does anyone know why the empty row stays in place. Why Isn't it removed completely? I use <code>setVisibility(View.GONE)</code> to make the <code>TextViews</code> disappear.</p>
  
  <p>When I simply use <code>Textviews</code> with <code>LinearLayouts</code> and set the visibilty to <code>GONE</code> the entire row disappears and the rows beneath automatically readjust accordingly.</p>
  
  <p><strong>EDIT</strong> : I edited the code to now include <code>adapter.remove(adapter.getItem(position))</code> and it causes my application to crash. I added the error log and edited code. Please help.</p>
  
  <p><strong>Edited</strong> code:</p>
  
  <pre><code>package com.example.listview;
  
  public class MainActivity extends ActionBarActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          populateListView();
          registerClickCallback();
      }
  
      private void populateListView() {
  
          //Create list of items
          String[] myItems = {"Blue", "Green","Purple","Red"};
  
          //Build Adapter
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.items, myItems);
  
          //Configure the list view
          ListView list = (ListView) findViewById(R.id.listView1);
          list.setAdapter(adapter);
      }
  
      private void registerClickCallback() {
          ListView list = (ListView) findViewById(R.id.listView1);
          list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
  
              @Override
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                      int position, long id) {
  
                  TextView textview = (TextView) view;
                  textview.setVisibility(View.GONE);
                  adapter.remove(adapter.getItem(position));
              }
      }); 
  }
  
  }
  </code></pre>
  
  <p>Error Log:</p>
  
  <pre><code>12-19 12:04:57.994: E/AndroidRuntime(23120): FATAL EXCEPTION: main
  12-19 12:04:57.994: E/AndroidRuntime(23120): Process: com.example.listview, PID: 23120
  12-19 12:04:57.994: E/AndroidRuntime(23120): java.lang.UnsupportedOperationException
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at java.util.AbstractList.remove(AbstractList.java:638)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:75)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at java.util.AbstractCollection.remove(AbstractCollection.java:229)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.widget.ArrayAdapter.remove(ArrayAdapter.java:244)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at com.example.listview.MainActivity$1.onItemClick(MainActivity.java:50)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.widget.AdapterView.performItemClick(AdapterView.java:298)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.widget.AbsListView.performItemClick(AbsListView.java:1113)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.widget.AbsListView$PerformClick.run(AbsListView.java:2911)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.widget.AbsListView$3.run(AbsListView.java:3645)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.os.Handler.handleCallback(Handler.java:733)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.os.Handler.dispatchMessage(Handler.java:95)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.os.Looper.loop(Looper.java:136)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at android.app.ActivityThread.main(ActivityThread.java:5146)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at java.lang.reflect.Method.invokeNative(Native Method)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at java.lang.reflect.Method.invoke(Method.java:515)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:796)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:612)
  12-19 12:04:57.994: E/AndroidRuntime(23120):    at dalvik.system.NativeStart.main(Native Method)
  </code></pre>