I am trying to display an array of words into a spinner from the database. The content is showing quite alright but it is all showing in one line instead of each word having its own line. e.g Wifi,Lifts,Ramps. I want each word to be on its won line and without the comma. here is the code i have used
Database
public Cursor getAllRows() {
String where = null;
Cursor c = db.query(true, DATABASE_TABLE, ALL_KEYS,
where, null, null, null, KEY_STATION_NAME, null);
if (c != null) {
c.moveToFirst();
}
return c;
}
Java file
public void loadtospinner() {
Spinner spFacilityType = (Spinner) findViewById(R.id.spinnerFacilityType);
Cursor c = dbHelper.getAllRows();
ArrayList<String> al = new ArrayList<String>();
c.moveToFirst();
while (!c.isAfterLast()) {
String name = c.getString(c.getColumnIndex(dbHelper.KEY_FACILITIES_TYPE));
al.add(name);
c.moveToNext();
}
ArrayAdapter<String> aa1 = new ArrayAdapter<String>(
getApplicationContext(), R.layout.spinner_item, R.id.textView1,
al);
spFacilityType.setAdapter(aa1);
// closing database
dbHelper.close();
}
Aucun commentaire:
Enregistrer un commentaire