Prevent OnItemSelectedListener from being called in response to setSelection
Whenever I call setSelection for my spinners, I OnItemSelectedListener is
called. In some specific cases it breaks my app. In other words, this has
to stop happening. The problem is that OnItemSelectedListener seems to be
called through the message queue. A trivial solution doesn't work:
private void setCurrentItemInCbCS(int ct, int id)
{
m_bControlChanging = true;
sp.setSelection(adapter.ordById(id));
m_bControlChanging = false;
}
private class SpinnerItemSelected implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> view, View textView, int
ord, long arg3) {
if (m_bControlChanging)
return;
// Do work...
}
public void onNothingSelected(AdapterView<?> arg0) {}
}
How can I solve the problem?
No comments:
Post a Comment