Android Spinner Selected Item

前端 未结 6 2164
花落未央
花落未央 2020-12-14 13:13

I am populating a spinner from the database like this

    // Populating the City Spinner
    Cursor cities = db.cityList();
    startManagingCursor(cities);
         


        
6条回答
  •  一整个雨季
    2020-12-14 13:49

    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 = yourCityList[position].toString(); // dont 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....

提交回复
热议问题