Esempio n. 1
0
  private void populateListViews() {
    // THIS HERE WILL POPULATE BOTH TEAM LIST VIEWS
    // Create list of items
    Cursor cursor = db.getTeams();

    ArrayList<String> values = new ArrayList<String>();
    if (cursor != null && cursor.getCount() != 0) {
      cursor.moveToFirst();
      while (!cursor.isAfterLast()) {

        values.add(cursor.getString(cursor.getColumnIndex("Team_Names")));

        cursor.moveToNext();
      }
    }
    // Build Adapter
    ArrayAdapter<String> t1adapter =
        new ArrayAdapter<String>(
            this, // Context
            R.layout.teamlistviews, // Layout to use
            values); // Items to be displayed
    // Configure the List View
    ListView t1list = (ListView) findViewById(R.id.listView1);
    t1list.setAdapter(t1adapter);

    cursor.close();
  }