title: ListView / ListAdapter with 2 strings in Android project
body: <p>I am working on Android project. I follow tutorial from <a href="http://www.vogella.com/articles/AndroidSQLite/article.html" rel="nofollow">http://www.vogella.com/articles/AndroidSQLite/article.html</a> but I stuck on something. Tutorial shows how to use Class with 1 String object. I am working with 2 String objects. So I changed few things (add new String to my class, change layout.simple_list_item_1 to  android.R.layout.simple_list_item_2 etc.) And now the question is - how to make something to get Stoliki class objects (override toString() gives me only 1 item, so It's useless).</p>
  
  <h1>Class Stoliki</h1>
  
  <pre><code>public class Stoliki {
        private long id;
        private String numer;
        private String opis;
  
        public long getId() {
          return id;
        }
  
        public void setId(long id) {
          this.id = id;
        }
  
        public String getNumer() {
          return numer;
        }
  
        public void setNumer(String numer) {
          this.numer = numer;
        }
  
        public String getOpis() {
              return opis;
          }
  
        public void setOpis(String opis) {
              this.opis = opis;
          }
  
      } 
  </code></pre>
  
  <h1>Activity</h1>
  
  <pre><code>import android.app.ListActivity;
  import android.os.Bundle;
  import java.util.List;
  import java.util.Random;
  import android.view.View;
  import android.widget.ArrayAdapter;
  
  public class FirstGridPage extends ListActivity {
        private StolikiDataSource datasource;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_view_list_stoliki);
  
      datasource = new StolikiDataSource(this);
      datasource.open();
  
      List&lt;Stoliki&gt; values = datasource.getAllStoliki();
  
      // Use the SimpleCursorAdapter to show the
      // elements in a ListView
      ArrayAdapter&lt;Stoliki&gt; adapter = new ArrayAdapter&lt;Stoliki&gt;(this,
          android.R.layout.simple_list_item_1, values);
      setListAdapter(adapter);
    }
  
    // Will be called via the onClick attribute
    // of the buttons in main.xml
    public void onClick(View view) {
      @SuppressWarnings("unchecked")
      ArrayAdapter&lt;Stoliki&gt; adapter = (ArrayAdapter&lt;Stoliki&gt;) getListAdapter();
      Stoliki stolik = null;
      switch (view.getId()) {
      case R.id.add:
        String[] stoliki_numer = new String[] { "1", "2", "3" };
        String[] stoliki_opis = new String[] { "Czerwony", "Niebieski", "Zielony" };
        int nextInt = new Random().nextInt(3);
        // Save the new comment to the database
        stolik = datasource.createStolik(stoliki_numer[nextInt], stoliki_opis[nextInt]);
        adapter.add(stolik);
        break;
      case R.id.delete:
        if (getListAdapter().getCount() &gt; 0) {
            stolik = (Stoliki) getListAdapter().getItem(0);
          datasource.deleteStolik(stolik);
          adapter.remove(stolik);
        }
        break;
      }
      adapter.notifyDataSetChanged();
    }
  
    @Override
    protected void onResume() {
      datasource.open();
      super.onResume();
    }
  
    @Override
    protected void onPause() {
      datasource.close();
      super.onPause();
    }
  
  } 
  </code></pre>