因为您使用的是微调器的数组资源,所以创建一个资源句柄
使用本地数组声明
getResources().getStringArray(R.array.framesps);
然后使用该句柄使用位置变量访问所选项目:
items[pos]
下面是代码编辑:
Spinner spinnerFPS = (Spinner) findViewById(R.id.sp_FPS);
String[] items=getResources().getStringArray(R.array.framesps);//handle to your arrays
ArrayAdapter adapter = ArrayAdapter.createFromResource(
this, items, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerFPS.setAdapter(adapter);
spinnerFPS.setOnItemSelectedListener(new YourItemSelectedListener());
public class YourItemSelectedListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView> parent, View view, int pos, long id) {
String selected =items[pos]; // use handler to access select item
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
}