填充spinner我有兩個片段A活性。其中之一是一個微調。當我填充它時,應用程序崩潰。 我不知道爲什麼。在android開發者中,它是如何在片段中感到困惑的,它看起來與正常活動不同。錯誤的片段
謝謝!
public class InstrumentsFrag extends Fragment {
TextView tv1;
Spinner sp;
String[] os = {"Cupcake v1.5", "Donut v1.6", "Éclair v2.0/2.1", "Froyo v2.2",
"Gingerbread v2.2", "Honeycomb v3.0/3.1"};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.instruments, container, false);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
sp = (Spinner) getActivity().findViewById(
R.id.spinner1);
ArrayAdapter <CharSequence>adapter = ArrayAdapter.createFromResource(getActivity(), R.array.sections , android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(adapter);
}
發佈logcat錯誤消息。 – kosa 2012-02-19 18:29:36