Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Eclipse all Spinner fonts became white

In my project, all Spinner fonts suddenly became white for a reason I can't find. Before all of them were black. For example, in a spinner, the dropdown list comes all in white. It's XML file is as follows;

<Spinner
    android:id="@+id/mainactivity_spinner_city"
    android:fontFamily="Roboto"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_below="@+id/mainactivity_imageview_logo"
    android:layout_marginTop="15dp"  />

In order to make sure, I added #000000 to all related places, but the list is still white. The spinner gets populated with the following method;

ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(context, android.R.layout.simple_spinner_item, list);
    dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(dataAdapter2);

So I added black color to simple_spinner_item and simple_spinner_dropdown_item as well but still no change. In Java part, I do not do anything related to color. What may be causing all these texts being white?

Edit: Only spinners have problem. I can change other elemens' text colors. But I can't change spinners even though I inserted textColor:"#000000" to anywhere related with spinners.

like image 866
Faruk Yazici Avatar asked Aug 18 '14 07:08

Faruk Yazici


2 Answers

Reason has been found.

While I was tackling with other spinners in other program, I realized that this strange fact caused the font becoming white. Even this question looks like a styling problem, underlying reason is about application context. In my old code, I used the following code for populating Spinner;

ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, list);

Then I changed the context parameter as follows;

ArrayAdapter<String> adapter= new ArrayAdapter<String>(MainActivity.this, android.R.layout.simple_spinner_item, list);

Then all undesired white fonts became black!!

If you use getApplicationContext() as a context parameter, some of your styling may be improper. So trying to call the context directly hardcoded like YourActivity.this in the adapter will solve the problem.

like image 198
Faruk Yazici Avatar answered Oct 11 '22 05:10

Faruk Yazici


The theme style applied to your project may cause this problem, try changing the theme attribute in you manifest.The whole app text color only can get changed from the theme style. try removing the theme tag from manifest file, and check color if it changes to default then you can create your own theme with any color text to apply on it.

like image 37
Raviindra Avatar answered Oct 11 '22 06:10

Raviindra