Spinner text color and dropdown color are the same
I have 2 spinners in my activity. One of the contributors, comExpiry, is populated based on a value selected from another Spinner, comSpinner. However, I ran into an issue where comSpinner is displayed correctly and comExpiry both text and background color are set to white in the emulator running ICS and therefore not readable.
Note that it works great in both Froyo and Gingerbread. I noticed that the spinner is displayed as intended if I remove the listener attached to the comSpinner. I have searched everywhere but cannot find a solution. Any help would be much appreciated.
comSpinner = (Spinner) findViewById(R.id.watchListSpinnetComm);
comExpiry = (Spinner) findViewById(R.id.watchListSpinnerExpiry);
ArrayAdapter<String> expAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
McxCommApp.comSelect.get(0));
expAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
comExpiry.setAdapter(expAdapter);
myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, McxCommApp.comName);
myAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
comSpinner.setAdapter(myAdapter);
comSpinner.setOnItemSelectedListener(new myListener());
ItemSelectedListener code looks like this:
public class myListener implements OnItemSelectedListener {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
expAdapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.spinner_a,
McxCommApp.comSelect.get(pos));
expAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
comExpiry.setAdapter(expAdapter);
}
public void onNothingSelected(AdapterView<?> parent) {
// Do nothing.
}
}
XML segment defining layout:
<TableRow
android:id="@+id/watchListTable"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Spinner
android:id="@+id/watchListSpinnetComm"
android:layout_height="32dip"
android:layout_column="1"
android:layout_gravity="center_vertical"
android:paddingLeft="5dip" />
<Spinner
android:id="@+id/watchListSpinnerExpiry"
android:layout_width="145dip"
android:layout_height="32dip"
android:layout_column="2"
android:layout_gravity="center_vertical"
android:paddingLeft="5dip" />
<Button
android:id="@+id/watchListAdd"
android:layout_width="wrap_content"
android:layout_height="40dip"
android:layout_gravity="center_vertical"
android:text="+"
android:textAppearance="?android:attr/textAppearanceLarge" />
</TableRow>
+3
source to share
No one has answered this question yet
Check out similar questions: