title: Remove button in gridview
body: <p>I have a gridview with 8 buttons, 2 rows and 4 columns.  I am trying to delete a button or even a row..a row might be better..I want this deletion to take place when I click on a button..any button.  I am having trouble with this.  I will show you code so far:</p>
  
  <p>Mainactivity:</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  private TextView text;
  private GridView gridView;
  private TextView timerValue;
  private Boolean firstclick = false;
  private long startTime = 0L;
  private Handler customHandler = new Handler();
  private Button buttonclicked;
  Random r = new Random();
  //private int[] rannumbers_array = new int[32];
  private int[] shuffle_array = new int[4];
  private String[] items = new String[8];
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      text = (TextView) findViewById(R.id.feedback);
      timerValue = (TextView) findViewById(R.id.timerValue);
      timerValue.setTextColor(Color.GREEN);
      int j = 0;
      int k = 0;
      int ranval = 0;
      for(int i = 0; i &lt; 8; i++)
      {
          if ( (i % 4) == 0)
          {
              for(int x = 0; x &lt; 4; x++)
              {
                  shuffle_array[x] = 0;
              }
              do {
                  ranval = r.nextInt(100);
              } while((ranval % 2) != 0);
          }
          else
          {
              do {
                  ranval = r.nextInt(100);
              } while((ranval % 2) == 0); 
          }
          shuffle_array[j] = ranval;
          j++;
          if(j &gt;= 4)
          {
              j = 0;
              shuffle(shuffle_array);
              do {
                 items[k] = Integer.toString(shuffle_array[j]);
                 k++;
                 j++;
              } while(k &lt;= i);
              j = 0;
          }
          //rannumbers_array[i] = r.nextInt(100);
          //items[i] = Integer.toString(rannumbers_array[i]);
      }
      k = 0;
  
  
  
  
      gridView = (GridView) this.findViewById(R.id.myGridView);
      final CustomGridAdapter gridAdapter = new CustomGridAdapter(MainActivity.this, items);
      gridView.setAdapter(gridAdapter);
      buttonclicked = gridAdapter.getbutton();
      gridView.post(new Runnable() {
          public void run() {
              gridView.setSelection(gridView.getCount() - 1);
          }
      });
      gridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              if(!firstclick)
              {
                 customHandler.postDelayed(updateTimerThread, 0);
                 firstclick = true;
              }
              buttonclicked.setVisibility(view.GONE);
  </code></pre>
  
  <p>my CustomGridAdapter:</p>
  
  <pre><code>public class CustomGridAdapter extends BaseAdapter {
  
  private Context context;
  private String[] items;
  private Button button;
  LayoutInflater inflater;
  
  public CustomGridAdapter(Context context, String[] items) {
      this.context = context;
      this.items = items;
      inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  }
  
  public View getView(int position, View convertView, ViewGroup parent) {
  
      if (convertView == null) {
          convertView = inflater.inflate(R.layout.cell, null);
      }
      button = (Button) convertView.findViewById(R.id.grid_item);
      button.setHeight(175);
      button.setText(items[position]);
  
      return convertView;
  }
  
  @Override
  public int getCount() {
      return items.length;
  }
  
  @Override
  public Object getItem(int position) {
      return items[position];
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  
  public Button getbutton()
  {
      return button;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>cell.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;Button xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:id="@+id/grid_item"
  android:layout_gravity="center"
  android:maxHeight="175dip"
  android:layout_marginLeft="20dip"
  android:textAppearance="?android:attr/textAppearanceMedium"
  android:text="05"
  android:textSize="25sp"
  android:clickable="false"
  android:focusable="false"/&gt;
  </code></pre>
  
  <p>activitymain.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:id="@+id/container"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  tools:context=".MainActivity"
  tools:ignore="MergeRootFrame" &gt;
  
  &lt;TextView
      android:id="@+id/timerValue"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="2dp"
      android:text="@string/timerVal"
      android:textColor="#ffffff"
      android:textSize="30sp" /&gt;
  
  &lt;GridView
      android:id="@+id/myGridView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerInParent="true"
      android:columnWidth="90dp"
      android:horizontalSpacing="0dp"
      android:numColumns="4"
      android:verticalSpacing="0dp" /&gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textAppearance="?android:attr/textAppearanceLarge"
      android:id="@+id/feedback"
      android:layout_alignParentBottom="true"
      android:layout_centerHorizontal="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>The buttonclicked.setVisibility(view.GONE); did not work, gave me an error I think.  I am trying to have a button or item be clicked and have that item and/or the row the item is in to be deleted..how can I do this?  What am I missing?  After the deletion occurs I will need to redraw the grid to have less items in it too.  Those are the two things that I am stumped on now</p>