0

I want to get value of choosed option in Spinner. I know, I can get this from setOnItemSelectedListener, but I don't want to use this. I have this:

String spinner1odp  = spinnerSubject.getSelectedItem().toString();

But result of this code is: android.database.sqlite.SQLiteCursor@40f828e8. I want to get String, not something like that :/

user1019901
  • 561
  • 3
  • 5
  • 11

2 Answers2

1

I think you are popping up Spinner from database. So considering that you will have to get the selected index first and fetch the required data from the Cursor:

Code Snippet :

int position = mySpinner.getSelectedItemPosition(); 
Cursor cursor = (Cursor) myAdapter.getItem(position);
String myText = cursor.getString(cursor.getColumnIndex(KEY_NAME));

Further Reference : Android Spinner Selected Item

Community
  • 1
  • 1
Kartik Domadiya
  • 29,868
  • 19
  • 93
  • 104
0

By using this code you can get...

String value= (String)spinnerSubject.getItemAtPosition(spinnerSubject.getSelectedItemPosition());

Venkat
  • 3,447
  • 6
  • 42
  • 61