我在应用程序中使用了两个Spinners
,并且在两个主题上都应用了深色样式主题,但是只有一个可以使用,即另一个Spinner
上的文本仍然是黑色,我想将其更改为白色,我尝试了一些修复程序,但对我没有用。
为了方便起见,还附上了它。
提前谢谢!
<LinearLayout
android:id="@+id/slyt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/textView4"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp">
<Spinner
android:id="@+id/spin1"
android:layout_width="159dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:entries="@array/acc_type"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</Spinner>
<Spinner
android:id="@+id/spin2"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
</Spinner>
</LinearLayout>
Java代码:
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
// TODO Auto-generated method stub
String sp1= String.valueOf(s1.getSelectedItem());
//Toast.makeText(this, sp1, Toast.LENGTH_SHORT).show();
if(sp1.contentEquals("Doctor")) {
List<String> list = new ArrayList<String>();
list.add("Dentist");
list.add("Surgeon");
list.add("Psychiatrist");
list.add("Physiologist");
list.add("Neurologist");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dataAdapter.notifyDataSetChanged();
s2.setAdapter(dataAdapter);
}
if(sp1.contentEquals("Engineer")) {
List<String> list = new ArrayList<String>();
list.add("Civil");
list.add("Electrical");
list.add("IT");
list.add("Aerospace");
list.add("Chemical");
list.add("Biomedical");
ArrayAdapter<String> dataAdapter2 = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_dropdown_item, list);
dataAdapter2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
dataAdapter2.notifyDataSetChanged();
s2.setAdapter(dataAdapter2);
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}