android - Text on spinner is white on a white background -


the text on spinners white, , have no idea why.

enter image description here

this xml, nothing special

 <spinner      android:id="@+id/spinner_date"      android:layout_width="0dp"      android:layout_height="wrap_content"      android:layout_weight="1" /> 

and code

datespinner = (spinner) findviewbyid(r.id.spinner_date); selecteddate = calendar.gettime(); list<string> list = new arraylist<string>(); list.add(formatter.format(selecteddate)); dateadapter = new arrayadapter<string>(mcontext,             android.r.layout.simple_spinner_item, list); datespinner.setadapter(dateadapter); 

what reason text displayed in white?

edit: i've found reason, replaced mcontext parameter set in oncreate.

mcontext = getapplicationcontext(); 

now use d

ateadapter = new arrayadapter<string>(this,                 android.r.layout.simple_spinner_item, list); 

and works.

i have same problem , have found answer. dont use application context, instead, use getactivity() (if in fragment) or (if in activity), work

 dateadapter = new arrayadapter<string>(**this**,         android.r.layout.simple_spinner_item, list); 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -