title: Creating a custom grid board (as seen in board games)
body: <p>I'm very new to Android GUI design. I'm trying to create a board as seen below. The cells can have different colors, and should be clickable with a toast shown, such attributes. My current code has major problems. How can generate this type of view? I would suggest let's start from scratch as this might be very simple to create and my code is a mess. Thanks in advance.</p>
  
  <p><img src="https://i.stack.imgur.com/mjMeR.png" alt="enter image description here"></p>
  
  <pre><code>import java.util.ArrayList;
  
  import android.app.Activity;
  import android.content.Context;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.Button;
  import android.widget.GridView;
  
  public class GridViewActivity extends Activity {
  
  private GridView list;
  ArrayList&lt;String&gt; data = new ArrayList&lt;&gt;();
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.gridview);
      for (int i = 0; i &lt; 10; i++) {
          for(int j=0;j&lt;20;j++)
          data.add(i+"-"+j);
      }
      GridViewCustomAdapter adapter = new GridViewCustomAdapter(this, data);
  
      list = (GridView) findViewById(R.id.grid_view);
      list.setAdapter(adapter);
  
  }
  }
  </code></pre>
  
  <p>and </p>
  
  <pre><code>import java.util.ArrayList;
  import android.app.Activity;
  import android.content.Context;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.Button;
  
  public class GridViewCustomAdapter extends BaseAdapter {
  
      ArrayList&lt;String&gt; items;
  
      static Activity mActivity;
  
      private static LayoutInflater inflater = null;
  
      public GridViewCustomAdapter(Activity activity, ArrayList&lt;String&gt; tempTitle) {
          mActivity = activity;
          items = tempTitle;
  
          inflater = (LayoutInflater) activity
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      }
  
      @Override
      public final int getCount() {
  
          return items.size();
  
      }
  
      @Override
      public final Object getItem(int position) {
          return items.get(position);
      }
  
      @Override
      public final long getItemId(int position) {
  
          return position;
      }
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
  
          View v = null;
  
          v = inflater.inflate(R.layout.item, null);
  
          Button tv = (Button) v.findViewById(R.id.button);
          tv.setText(items.get(position));
  
          return v;
      }
  
  }
  </code></pre>