I am using a spinner using following code
private String `DEFAULT_CURRENCY_TYPE`;
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item, currenciesDataSource.keys);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
paidIn.setAdapter(adapter);
I want to do something like that paidIn.setDefault(DEFAULT_CURRENCY_TYPE)
Meaning whenever i create spinner it compare its values with my default values and then set it as first element. How can i do that?
Best Regards
尝试这个:
spinner.setSelection(adapter.getPosition(DEFAULT_CURRENCY_TYPE))
我认为你可以使用spinner.setSelection(position)可能是解决方案,如果我清楚地理解你的问题
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.