Help!!! Spinner 1: here is the xml of the Spinner I have, Its with white background and black text color for the items. I want it to have a Black Background with white text.
XML:
<Spinner android:id="@+id/categorySpinner" android:layout_width="369dp" android:layout_height="41dp" android:layout_margin="12dp" android:spinnerMode="dropdown" android:entries="@array/category_items" android:paddingLeft="16dp" android:layout_weight="1" android:background="#FFFFFF" />
Java:
ArrayAdapter<CharSequence> categoryAdapter = ArrayAdapter.createFromResource(this.getApplicationContext(), R.array.category_items, android.R.layout.simple_spinner_item); categoryAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); categorySpinner.setAdapter(categoryAdapter); categorySpinner.setSelection(0, false); // Set the hint item as selected
Note: The attribute android:textColor="#000000" is not working for this.
Spinner 2
For the 2nd Spinner below, I want it to have a rounded black color border .
XML:
<Spinner android:id="@+id/conditionSpinner" android:layout_width="369dp" android:layout_height="41dp" android:layout_margin="12dp" android:spinnerMode="dropdown" android:entries="@array/condition_items" android:paddingLeft="16dp" android:textColor="#FFFFFF" android:background="@drawable/spinner_border" />
Java:
ArrayAdapter<CharSequence> conditionAdapter = ArrayAdapter.createFromResource(this, R.array.condition_items, android.R.layout.simple_spinner_item); conditionAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); conditionSpinner.setAdapter(conditionAdapter); conditionSpinner.setSelection(0, false); // Set the hint item as selected
For Spinner 1, I want it to have a Black Background with white text. For Spinner 2, I want it to have a black rounded border
categorySpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view,
int position, long id) {
((TextView) view).setTextColor(Color.WHITE);
((TextView) view).setBackgroundColor(Color.BLACK);
if (position == 0){
Luxury();//code for Luxury
}
else if (position == 1){
Tech();//code for Tech
}
else if (position == 2){
Clothes();//code for Clothes
}
else if (position == 2){
Furniture();//code for Furniture
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
ArrayAdapter<CharSequence> categoryAdapter = new ArrayAdapter<CharSequence> (getActivity(), android.R.layout.simple_spinner_item, category_items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
categorySpinner.setAdapter(adapter);