To get the selected counter value, you can follow this.
Create a nested class that implements AdapterView.OnItemSelectedListener. This will provide a callback method that will notify your application when an item has been selected from Spinner.
Inside the onItemSelected method of this class, you can get the highlighted element:
public class YourItemSelectedListener implements OnItemSelectedListener { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { String selected = parent.getItemAtPosition(pos).toString(); } public void onNothingSelected(AdapterView parent) {
Finally, your ItemSelectedListener must be registered with Spinner:
spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
jalopaba Apr 16 2018-10-16T00: 00Z
source share