I want read out the customers from db and populating them in a Spinner. The code below makes no errors, but I want that customers with the same First and Lastname should be shown only one time in the spinner, not twice. That's not working, how can I do that?
DBHelper
public String[] getCustomerList() {
String query = "Select * FROM " + CUSTOMER;
SQLiteDatabase db = this.getWritableDatabase();
ArrayList<String> cusList = new ArrayList<String>();
Cursor cursor = db.rawQuery(query, null);
if (cursor.moveToFirst()) {
do {
cusList.add(cursor.getString(cursor.getColumnIndex(COLUMN_FIRSTNAME)) + " "
+ cursor.getString(cursor.getColumnIndex(COLUMN_SECONDNAME)));
}
while (cursor.moveToNext());
}
String[] result = cusList.toArray(new String[cusList.size()]);
Arrays.sort(result);
return result;
}
Method getCustomerList()
private String[] getCustomerList() {
String[] customerList;
customerList= dbHelper.getcustomerList();
filling ArrayAdapter..
adapterCar = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, getCustomerList());
Aucun commentaire:
Enregistrer un commentaire