I am working on an Android app. I have 2 spinners in a LinearLayout with a few other EditText. The Spinner on the top shows the radio button with each item in the list. The second one does not and each row in the second Spinner is much thinner than the first Spinner. Here is my xml code.
<Spinner
android:id="@+id/new_type"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/list_prompt"
android:textColorHint="@android:color/white" />
<Spinner
android:id="@+id/new_course"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:prompt="@string/enter_course"
android:textColorHint="@android:color/white" />
Here is my java code.
Spinner spinner = (Spinner) findViewById(R.id.new_type);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.type_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
Spinner cSpinner = (Spinner) findViewById(R.id.new_course);
ArrayAdapter<CharSequence> cAdapter = ArrayAdapter.createFromResource(this,
R.array.course_array, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
cSpinner.setAdapter(cAdapter);
The 2 Spinners are almost identical I cant figure out why there is so much difference between the 2. Any help is greatly appreciated thanks.
You are declaring a new
ArrayAdapterwith the namecAdapterbut one line below you aresetting the drop down view resource to the previous adapter.
To fix it change this line:
to
Fixed 🙂