adapter=new ArrayAdapter(this,android.R.layout.simple_spinner_item,mStrings);
android.widget.ArrayAdapter.ArrayAdapter(Context context, int textViewResourceId, String[] objects)
/*
*public ArrayAdapter(Context context, int textViewResourceId, T[] objects)
*Constructor
*Parameters
*context 当前上下文
*textViewResourceId 当初始化views时,包含一个文本视图的文件所对应的资源ID值。The resource ID for a layout file containing a *TextView to use when instantiating views.
*objects 在列表视图中所代表的对象。The objects to represent in the ListView.
*/
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
s.setAdapter(adapter);
/*
*void android.widget.ArrayAdapter.setDropDownViewResource(int resource)
*public void setDropDownViewResource(int resource)
*设置布局资源来设置下拉视图。
*Sets the layout resource to create the drop down views.
*Parameters
*resource 定义下拉资源的布局资源the layout resource defining the drop down views
*See Also
* getDropDownView(int, android.view.View, android.view.ViewGroup)
*/
s.setOnItemSelectedListener(this);
/*
*void android.widget.AdapterView.setOnItemSelectedListener(OnItemSelectedListener listener)
*public void setOnItemSelectedListener(AdapterView.OnItemSelectedListener listener)
*注册一个回调函数用来在当一个选项在此适配器视图中被选中时执行
*Register a callback to be invoked when an item in this AdapterView has been selected.
*Parameters
*listener 将要执行的响应函数The callback that will run
*/