在片段中设置微调器

我正在尝试从我的public final class Manual extends Fragment中的onCreateView中的一个片段中的字符串数组设置我的微调器的值。 public final class Manual extends Fragment

 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.manual, container, false); String [] values = {"Time at Residence","Under 6 months","6-12 months","1-2 years","2-4 years","4-8 years","8-15 years","Over 15 years",}; Spinner spinner = (Spinner) v.findViewById(R.id.spinner1); ArrayAdapter LTRadapter = new ArrayAdapter(this.getActivity(), android.R.layout.simple_spinner_item, values); LTRadapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); spinner.setAdapter(LTRadapter); return inflater.inflate(R.layout.manual, container, false); } 

我的代码没有错误,但它没有设置微调器。 微调器保持空白,没有值。 关于为什么我的代码没有设置微调器的任何想法?

问题是我正在返回一个新视图,而不是我设置的视图。 我不得不return v; 它工作得很好。

 @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.manual, container, false); String [] values = {"Time at Residence","Under 6 months","6-12 months","1-2 years","2-4 years","4-8 years","8-15 years","Over 15 years",}; Spinner spinner = (Spinner) v.findViewById(R.id.spinner1); ArrayAdapter adapter = new ArrayAdapter(this.getActivity(), android.R.layout.simple_spinner_item, values); adapter.setDropDownViewResource(android.R.layout.simple_dropdown_item_1line); spinner.setAdapter(adapter); return v; }