What i want is the Text color of the spinner should be white at runtime when it is displayed inside the Spinner as it is in spinner 1 and 2 and the text color of the list of Spinner should be black as in the picture.
The problem is i am able to do it for the first 2 Spinners but fail to do it for the 3rd and the 4th Spinner.
If you can see the 3rd and 4th Spinner has values but in black. I don't understand that if its possible for 2 spinners then y not for all 4. please help me.
This is my code to change color at runtime:
public class Text // class for changing the text color of spinner
{
private TextView tv = null;
Text(View spin_adptr)
{
tv = (TextView) spin_adptr.findViewById(R.id.textspin);
tv.setTextColor(Color.WHITE);
}
}
and this is how i am calling it:
public void onItemSelected(AdapterView<?> parent, View arg1, int position,
long arg3) {
int id = parent.getId();
Text text = new Text(spinner1); //Change of color (Working)
Text text1 = new Text(spinner3); //Change of Color(ERROR)
Text text2 = new Text(spinner4); //Change of Color(ERROR)
switch (id) {
case R.id.spinner1:
String b = spinner1.getSelectedItem().toString();
if (b != null) {
dbCarHelper.make_pop(b);
}
List<String> lb = h.getAllLabels();
ArrayAdapter<String> dAdapter = new ArrayAdapter<String>(this,
R.layout.spin_adptr,lb);
dAdapter.setDropDownViewResource(R.layout.spin_adptr);
spinner2.setAdapter(dAdapter);
break;
case R.id.spinner2:
Text text1 = new Text(spinner2); //// Change of color (working)
String a = spinner2.getSelectedItem().toString();
if (a != null) {
dbCarHelper.m_pop(a);
}
CarHelper c = new CarHelper(getApplicationContext());
List<String> lable = c.getAllLabel();
ArrayAdapter<String> dAdaptr = new ArrayAdapter<String>(this,
R.layout.spin_adptr,lable);
dAdaptr.setDropDownViewResource(R.layout.spin_adptr);
spinner3.setAdapter(dAdaptr);
break;
}
}
make a xml file named as spinner_layout and write code as below
make another xml named as spinner_dropdown and write below code
now update your code as below