title: Button in gridview with database
body: <p>I like making so that buttons be arranged in the page.</p>
  
  <p>But the number of button depends on the number of datum stored in the database.</p>
  
  <p>To do it, every button has a title stored in the database.</p>
  
  <p>Buttons display well in the page, but I do not manage to make them clickable.</p>
  
  <pre><code>    private void displayGridView() {
      final Cursor cursor = MessagesBDD.fetchAllMessage();
  
      // The desired columns to be bound
      String[] columns = new String[]{MessagesBDD.COL_TITRE,};
  
      final GridView gridview = (GridView) findViewById(R.id.fragboutton);
      int[] to = new int[]{R.id.button9,};
      final SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.fragment_button, cursor, columns, to, 0);
  
      gridview.setAdapter(adapter);
  
  }
  </code></pre>
  
  <p>In the OnCreate :</p>
  
  <pre><code>        //Création d'une instance de ma classe MessageBDD
      MessagesBDD messageBdd = new MessagesBDD(this);
  
      //On ouvre la base de données pour écrire dedans
      messageBdd.open();
  
      //Generate ListView from SQLite Database
      displayGridView();
      //Récupère le fragment permettant d'accèder à la liste des contacts
  </code></pre>
  
  <p>My Database :</p>
  
  <pre><code>public class Message {
  
  private int id;
  private String titre;
  private String contenu;
  
  public Message(){}
  
  public Message(String titre, String contenu){
      this.titre = titre;
      this.contenu = contenu;
  }
  
  public int getId() {
      return id;
  }
  
  public void setId(int id) {
      this.id = id;
  }
  
  public String getTitre() {
      return titre;
  }
  
  public void setTitre(String titre) {
      this.titre = titre;
  }
  
  public String getContenu() {
      return contenu;
  }
  
  public void setContenu(String contenu) {
      this.contenu = contenu;
  }
  
  public String toString(){
      return "ID : "+id+"\ntitre : "+titre+"\nContenu : "+contenu;
  }
  </code></pre>
  
  <p>Methode fetchAllMessage :</p>
  
  <pre><code>    public static Cursor fetchAllMessage() {
  
      Cursor mCursor = bdd.query(TABLE_MESSAGES, new String[] {COL_ID, COL_TITRE, COL_CONTENU}, null, null, null, null, null);
  
      if (mCursor != null) {
          mCursor.moveToFirst();
      }
      return mCursor;
  }
  </code></pre>
  
  <p>thanks for your help guys</p>