我尝试将项目从 android.support.v4.app.Fragment 类实现到 Spinner。我总是得到编译器错误
构造函数 ArrayAdapter(LayoutNext, int, String[]) 未定义
我怎样才能解决这个问题?这是代码:
public class LayoutNext extends Fragment
implements OnClickListener,OnItemSelectedListener{
TimePicker timepicker;
private Spinner spinner_next;
public ArrayAdapter<String> adapter;
public static Fragment newInstance(Context context) {
LayoutNext f = new LayoutNext();
return f;
}
public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {
ViewGroup root = (ViewGroup) inflater.inflate(R.layout.layout_next, null);
timepicker = (TimePicker) root.findViewById(R.id.timePicker1);
timepicker.setIs24HourView(true);
timepicker.setCurrentHour(0);
timepicker.setCurrentMinute(0);
String[] items_next = { "Next", "From to"};
spinner_next = (Spinner) root.findViewById(R.id.sp_next);
spinner_next.setOnItemSelectedListener(this);
// Here I get the error
ArrayAdapter<String> adapter = new ArrayAdapter<String>(
this,
android.R.layout.simple_spinner_item,
items_next);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_next.setAdapter(adapter);
return root;
}