嘿,我正在尝试使用 eclipse for android 将项目添加到微调器,并且在执行以下行时:
fromList.setAdapter(adapter);
调试器说
找不到来源。
这是我的java代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final List<String> list = new ArrayList<String>();
list.add("Item 1");
list.add("Item 2");
list.add("Item 3");
list.add("Item 4");
list.add("Item 5");
fromList = (Spinner) this.findViewById(R.id.spinnerFrom);
CharSequence[] itemArray = getResources().getTextArray(R.array.temperature_units);
List<CharSequence> itemList = new ArrayList<CharSequence>(
Arrays.asList(itemArray));
adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, itemList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
fromList.setAdapter(adapter); // THE ERROR HAPPENS HERE
}