Suppose I get a cursor that contains all rows from my database, and I
want to show them on a spinner, the following code will work. But I
want to show two extra items as the spinner elements, how can I add
those two elements?
For example, if the following code can show 4 spinner elements
"Orange" "Apple" "Cabbage" "Green Onion", how can I add an element in
the spinner saying "All fruit" "All Vegetable"?
Thanks
class ShowElements extends Activity {
.....
private void populateSpinner() {
Cursor cursor = mDbHelper.fetchAllExistingElements(); // get
all items
startManagingCursor(cursor);
String[] from = new String[]{ ShowElements.KEY_NAME };
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(
this, android.R.layout.simple_spinner_item, cursor,
from,
to);
adapter.setDropDownViewResource
(android.R.layout.simple_spinner_dropdown_item);
mCardSpinner.setAdapter(adapter);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---