I’ve populated my spinner as this:
DatabaseConnector dbConnector = new DatabaseConnector(this);
dbConnector.open();
Cursor c = dbConnector.raw("SELECT _id, nombrecasa FROM casa");
startManagingCursor(c);
String[] from = new String[]{"nombrecasa"};
int[] to = new int[]{android.R.id.text1};
SimpleCursorAdapter adapter =
new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, c, from, to );
adapter.setDropDownViewResource( android.R.layout.simple_spinner_dropdown_item );
casaSpinner = (Spinner) findViewById( R.id.casaspinner);
casaSpinner.setAdapter(adapter);
dbConnector.close();
}
And when I try to get the value as:
String idcasa = casaSpinner.getSelectedItem().toString();
it only returns this:
android.database.sqlite.SQLiteCursor@40539880
Your spinner has taken a
SimpleCursorAdapteras an adapter, of which its dataset is aCursor. When you select an item on the spinner, you’ve only moved the cursor to a specific row and when you callgetSelectedItem()you’re still requesting for the dataset object – which is still a cursor object. to do what you’re trying you can simply call:once your selection has been made. For something a little more fundamentary illustrative of what i said.