这是代码
dChooser= (Spinner) findViewById(R.id.spinner1);
adapter = new ArrayAdapter<CharSequence>(this,R.array.d_choices);
dChooser.setAdapter(adapter);
这里是xml部分,我不明白我做错了什么
<Spinner
android:id="@+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/time2"
android:layout_marginTop="24dp"
android:spinnerMode="dropdown"
android:background="@android:color/darker_gray" />
答案 0 :(得分:1)
您的适配器似乎错误使用此类
dChooser= (Spinner) findViewById(R.id.spinner1);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.d_choices, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dChooser.setAdapter(adapter);