1
我嘗試從android.support.v4.app.Fragment類實現項目到微調。我總是得到編譯器錯誤構造函數ArrayAdapter <String>(LayoutNext,int,String [])未定義
構造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;
}
非常感謝,它的作品! – user1390816 2013-03-24 16:21:06