I have tests where I test OnItemSelectedListener on Spinner. It works great when testing elements> 0. But it looks like I can't check the first element.
My current implementation, which works if I select items with index> 0, looks like this.
final Addpointer addPointer = getActivity(); addPointer.runOnUiThread(new Runnable() { @Override public void run() { EditText address = (EditText) addPointer.findViewById(R.id.address); address.setText("a"); Spinner spinner = (Spinner) addPointer.findViewById(R.id.intOrHex); spinner.setSelection(0); View view = (View) spinner.getChildAt(0); long id = spinner.getAdapter().getItemId(0); spinner.performItemClick(view, 0, id); } });
What do I need to do to get the test to "select" the first element?
Thanks in advance
Rolling
Answer: 1) Rahul garg about setting up "animate" was the key to solving the problem. 2) But you cannot activate onSelectionChanged if the selection has not actually changed (0 was the initial state, so I had to set it to a value before I return it to zero.
source share