1
我想改变微调器的文字颜色(我想让选定的值为白色)。Android - 微调器文字颜色变化不起作用
我在这个论坛上有关于这个主题的红色,但它不帮助我。我为我的微调(spin.xml)创建了布局xml文件。这里是我有:
spin.xml:在我的onCreate()
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top"
android:singleLine="true"
android:textColor="#ffffff" />
阵列适配器:
spinner = (Spinner) findViewById(R.id.shift);
// Create an ArrayAdapter using the string array and a default spinner layout
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.shiftarray, R.layout.spin);
// Specify the layout to use when the list of choices appears
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// Apply the adapter to the spinner
spinner.setAdapter(adapter);
spinner.setOnItemSelectedListener(new OnItemSelectedListener(){
public void onItemSelected(AdapterView<?> arg0, View view, int pos, long id) {
selected = spinner.getSelectedItem().toString();
((TextView) spinner.getChildAt(0)).setTextColor(1);
Log.e("SELECT", selected);
}
public void onNothingSelected(AdapterView parent) {
// Do nothing.
}
});
我应该怎么做,使它工作吗? 比你。 :)
你知道使用选择的?此外,我会去制作自定义适配器,并在getView()中做到这一点。 –