List of usage examples for android.widget Spinner getSelectedView
@Override
public View getSelectedView()
From source file:Main.java
public static void setSpinnerSelection(Spinner spinner, int position) { if (spinner.getSelectedItemPosition() != position) { spinner.setSelection(position);//from w w w . ja v a 2 s . c o m } else { spinner.getOnItemSelectedListener().onItemSelected(spinner, spinner.getSelectedView(), position, spinner.getAdapter().getItemId(position)); } }
From source file:com.money.manager.ex.account.AccountTransactionListFragment.java
private void loadAccountsInto(final Spinner spinner) { if (spinner == null) return;//www . j a v a2s .c o m AccountService accountService = new AccountService(getActivity()); accountService.loadTransactionAccountsToSpinner(spinner); // e switching of accounts. spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { // switch account. Cursor cursor = (Cursor) adapterView.getItemAtPosition(i); Account account = new Account(); account.loadFromCursor(cursor); int accountId = account.getId(); switchAccount(accountId); // color the spinner text of the selected item. int spinnerItemTextColor = ContextCompat.getColor(getActivity(), R.color.material_grey_50); ((TextView) spinner.getSelectedView()).setTextColor(spinnerItemTextColor); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); }