- This note is mainly used to record the use of various controls under Android to facilitate their own query:PS: Note that the listener for each control is not the same! A mistake can cause a program to crash!
- Spinner: The most important addition to the control is the array of choices:
- First, create a arrayadapter by two methods of creating Arrayadapter in the second record;
- The array is then initialized to a drop-down view through the Setdropdownviewresource () function;
- Finally, through the function Setadapter (), the created Arrayadapter can be set in.
- The code is as follows:
1Arrayadapter<charsequence> Timearray =NULL;2Timearray=arrayadapter.createfromresource ( This, R.array.playing_time_setting, Android. R.layout.simple_spinner_item);3 //timearray=new arrayadapter<string> (this,android. r.layout.simple_spinner_item,timestring); //two different methods4Timearray.setdropdownviewresource (Android. R.layout.simple_spinner_dropdown_item);//parameter is a simple drop-down view layout provided by Android5Timesetting.setadapter (Timearray);
- Spinner drop-down menu select the Listener function of the click, you must not be mistaken, or the program will crash;
Setonitemselectedlistener (new Spinner.onitemselectedlistener () { publicvoid onitemselected (adapterview<?> arg0, View arg1, intlong arg3) { } Public void onnothingselected (adapterview<?> arg0) { } });
Android Learning précis-writers--the third record