Ejemplo n.º 1
0
  private void setArmorsList(Object object) {
    int numCursorRows;

    // Determine the gifts to put in the list.
    Cursor c;
    try {
      c = myDbHelper.listGifts();
    } catch (SQLException sqle) {
      throw sqle;
    }
    numCursorRows = c.getCount();
    //		Log.d(TAG, "c has "+numCursorRows+" rows and "+c.getColumnCount()+" columns");
    stringArmors = new ArmorString[numCursorRows]; // create an array of proper size.
    c.moveToFirst();
    for (int i = 0; i < numCursorRows; i++) {
      stringArmors[i] = new ArmorString();
      stringArmors[i].name =
          c.getString(0); // This cursor has two columns companion name and faction side
      c.moveToNext();
    }

    // Build the listview
    // The adapter determines how to draw on screen.  The listview will ask the adapter to draw the
    // view
    // with adapter's getView method.
    MyArmorAdapter<ArmorString> adapter =
        new MyArmorAdapter<ArmorString>(this, android.R.layout.simple_list_item_1, stringArmors);

    listViewArmors.setAdapter(adapter);
    listViewArmors.setOnItemClickListener(new MyArmorsOnItemClickListener(this));
  }