问题
I'm using the spinner, and I want to get the text selected for the user so I'm using
String datacat = categorySpinner.getSelectedItem().toString()
the problem is that this sentence also return the tag of the spinner in a String like this: {supplier=VITA}
, but I need to get only the VITA
value
回答1:
Assuming selectedview is EditText.
String datacat =((EditText) categorySpinner.getSelectedView()).getText().toString();
回答2:
try
String datacat = categorySpinner.getSelectedView().getText().toString()
you may have to cast the view before you can call getText()
来源:https://stackoverflow.com/questions/9524343/how-to-get-spinner-value-without-tag