Anda mendapatkan data dari db di al
Daftar Array. Kemudian Anda dapat melakukan hal berikut
al.add(0, "YOUR MESSAGE");
Itu menambahkan string PESAN ANDA di 0th
indeks.
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
Setelah ini, berikan daftar ke arrayadapter
ArrayAdapter<String> aa1 = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_spinner_item,
al);
spn.setAdapter(aa1);
Silakan periksa ArrayList
EDIT
Ini kodenya
public void loadtospinner() {
ArrayList<String> al = new ArrayList<String>();
Cursor c = SQLcon.readData();
c.moveToFirst();
while (!c.isAfterLast()) {
String name = c.getString(c.getColumnIndex(DBhelper.MEMBER_NAME));
String calories = c.getString(c
.getColumnIndex(DBhelper.KEY_CALORIES));
al.add(name + ", Calories: " + calories);
c.moveToNext();
}
al.add(0, "YOUR MESSAGE"); // do this after while loop and that's it.
ArrayAdapter<String> aa1 = new ArrayAdapter<String>(
getApplicationContext(), android.R.layout.simple_spinner_item,
al);
spn.setAdapter(aa1);
// closing database
SQLcon.close();
}