我正在尝试在微调器列表中添加一些项目。但不知何故,我总是得到以下异常this
-
Cannot use this in a static context
下面是我的代码
public static void initSpinnerView(Context context, Spinner spinnerView, String prefix, int numItems, int layout) {
//spinnerView = (Spinner) findViewById(R.id.spinner2);
List<String> list = new ArrayList<String>();
list.add("list 1");
list.add("list 2");
list.add("list 3");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinnerView.setAdapter(dataAdapter);
}
}
谁能告诉我我在这里做错了什么?