If I pass my Spinner a simple array of Integers it works fine. But I want to make an exception of the value 0 (zero).
/*
* Pass the spinner the adapter with all possible start numbers.
*/
List<RiderStatus> RiderStatuses = DataModel.get().getRiderStatuses();
List<Integer> tempInts = new ArrayList<Integer>(
RiderStatuses.size() + 1);
for (int i = 0; i < RiderStatuses.size(); i++) {
if (i == 0 || (RiderStatuses.get(i).getStarted()
&& !RiderStatuses.get(i).getFinished()))
tempInts.add(new Integer(RiderStatuses.get(i).getRiderNum()));
}
ArrayAdapter<Integer> spinnerAdapter = new ArrayAdapter<Integer>(
mCallercontext, R.layout.big_spinner, tempInts);
/*
* Notify observers
*/
spinnerAdapter.notifyDataSetChanged();
viewHolder.spinnerStartNo = (Spinner) convertView.findViewById(R.id.spinnerStartNo);
viewHolder.spinnerStartNo.setAdapter(spinnerAdapter);
My Object is simply an Integer with the toString returning text for the zero case. I essentially replace Integer with my RiderNo in the code above. When I click on the spinner the screen dims and buttons become unresponsive or slow to respond.
This is the code for my Object.
/**
* Class RiderNo
* Holds an Integer, but implements toString so that an exception
* can be made of rider 0 - the "Bandit" or unknown.
* Use instead of Integer in tempInts. Did not work!
*/
private class RiderNo {
private Integer mRiderNo;
RiderNo(int riderNo) {
mRiderNo = riderNo;
}
public String toString() {
if( mRiderNo == 0 )
return "Bandit";
else
return String.format("%d", mRiderNo);
}
public int getRiderNo() {
return mRiderNo;
}
public void setRiderNo(int riderNo ) {
mRiderNo = riderNo;
}
}
Full disclosure: The surrounding code is quite complicated. I have a list view that is driven by a Queue (FIFO). The list view has two columns: a captured time and the Spinner in question with a list (changing subset) of numbers.
I now have more info:
This is in the Log
01-25 13:59:50.958 32029-32029/ca.owensoundcyling.tttimer W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
And there is already a question about that Attempted to finish an input event but input event receiver has already been disposed
There were two problems, at least I made two changes and it got incrementally better. After fixing the first, I got a real Exception in my code. But that probably was always a problem - just never got that far.