Android Spinner Selected Item?

I think, as you are using a customadapter and giving three lists in adapter you can't get the selected text simply by calling the getSelectedItem() Use this: Spinner mySpinner = (Spinner)findViewbyId(R.id. Spinner); int position = mySpinner. GetSelectedItemPosition(); String Text = yourCityListposition.toString(); // don't know which list is holding the city list... // I didn't use any db in any of my app so cant tell you how can you get list... // leaving it to you... :) Hope it helps.

I think, as you are using a customadapter and giving three lists in adapter... you can't get the selected text simply by calling the getSelectedItem().. Use this: Spinner mySpinner = (Spinner)findViewbyId(R.id. Spinner); int position = mySpinner. GetSelectedItemPosition(); String Text = yourCityListposition.toString(); // don't know which list is holding the city list... // I didn't use any db in any of my app so cant tell you how can you get list... // leaving it to you... :) Hope it helps....

Just get the adapter from your spinner and get the string from the cursor Cursor cursor = (Cursor) myAdapter. GetItem(position); String cityName = cursor. GetString(cursor.

GetColumnIndex(DBAdapter. KEY_NAME)).

Is there a way like in HTML to have the name and key value like in the option select options. – Harsha M V Apr 28 at 12:53 What exactly do you mean by key value – Mojo Risin Apr 28 at 12:54 am getting this error: position cannot be resolved – Harsha M V Apr 28 at 17:24 Volvo Saab like this. The display text is Car names but values are ids – Harsha M V Apr 28 at 17:52.

Not able to point to the code I need – Harsha M V Apr 28 at 17:42.

List list = new ArrayList(); s = (Spinner)findViewById(R.id. Spinner1); SQLiteDatabase sqldb = db.openDataBase(); Cursor cr = sqldb. RawQuery("select Name from employee",null); if (cr.moveToFirst()) { do { list.

Add(cr. GetString(0).toString()); Toast. MakeText(this,cr.

GetString(0).toString(),Toast. LENGTH_LONG).show(); ArrayAdapter a= new ArrayAdapter(this, android.R.layout. Simple_spinner_item,list); a.

SetDropDownViewResource(android.R.layout. Simple_spinner_dropdown_item); s. SetAdapter(a); } while (cr.moveToNext()); }//urvesh patel.

Int to = new int { android.R.id. Spinner cityList = (Spinner) this. SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, android.R.layout.

Spinner getCity = (Spinner) findViewById(R.id.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions