For details about the basic functions of the spinner, refer to androidgui03: common skills of the spinner.
Update:
The project has an interface that uses the choice of the spinner and then automatically reload the listview. At the beginning, the listview is manually added during oncreate. setadapter () is used to load data. Now it is not necessary. listview is also available in the onitemselected method of the spinner. setadapter () (this is used for loading). During debugging, it is found that the data is loaded twice. Originally, if you have a spinner, the system automatically calls onitemselected (and starts with the first item), which leads to duplicate load with my oncreate.
Update:
If you want to implement a data jump from the selected items of the previous listview to view2, The listview will jump back to the data of the items corresponding to the previous spinner. At the beginning, I only changed the textview word in onitemselected, and then changed the position when loading. Soon I found that this was just a pseudo practice, the selection items in the spinner are certainly unchanged. Now we find that android has a spinner. setselection (n, true) to select the selected item. Use this.
Previously, it was found that the first operation is selected by default after data adaptation. By default, the first operation is not executed immediately, but executed after a period of time, and the onitemselectedlistener event is triggered. However, if youUse spinner. setselection (2, true); Then, the system will not execute onitemselected at the beginning.
[Android] how to set the default value after data is filled in for the spinner?
Updata:
Found:
At the beginning, the system does not call onitemselected and the sequence of setonitemselectedlistener (this); setselection (spinneritem, true:
// Call onitemselected
Spinner. setonitemselectedlistener (this );
Spinner. setselection (spinneritem, true );
The onitemselected statement is not called if the two statements are exchanged.