I have a Spinner. After an item is selected, and the adapter is updated by notifyDataSetChanged, the selected item displayed in the Spinner (Textview) changes. This functionality is by design. Because the selected position stayed the same but the value of the selected position changed due to the new content from updating the adapter.
I want to continue to display the originally selected item after the adapter updates.
I was hoping this solution would work, but the event/lister never fires. Maybe because I am using a Spinner and the list is not dispalyed?
https://stackoverflow.com/a/29173680/2330272
mListView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
mListView.removeOnLayoutChangeListener(this);
Log.e(TAG, "updated");
}
});
mAdapter.notifyDataSetChanged();
Update Help with at least two questions:
How to determine when the Spinner has finished updating the view after the notifyDataSetChanged has been called for the adpater?
How to find the position (index) of a value (label) in the adapter? As the adapter be querued or elements loop thru?