Android 微调器文本不可见

Android 微调器文本不可见,android,spinner,Android,Spinner,我试图在微调器中setText,但在设备中不可见。(在模拟器中可见) 请给出解决方案。您不能使用settext()将settext设置为微调器。必须使用ArrayAdapter在微调器中显示内容。像这样, 声明数组- String[] type_array = {"Monthly","Quaterly","Yearly"}; 在onCreate()中- spinner\u type=(spinner)findViewById(R.id.spinner\u type\u susa); 微调器类型

我试图在
微调器中
setText
,但在设备中不可见。(在模拟器中可见)


请给出解决方案。

您不能使用settext()将settext设置为微调器。必须使用ArrayAdapter在微调器中显示内容。像这样,

声明数组-

String[] type_array = {"Monthly","Quaterly","Yearly"};
在onCreate()中-

spinner\u type=(spinner)findViewById(R.id.spinner\u type\u susa);
微调器类型。setOnItemSelectedListener(此);
ArrayAdapter\u type=新的ArrayAdapter(此,R.layout.spinner\u行,type\u数组);
adapter\u type.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
微调器类型。设置适配器(适配器类型);

您为文本提供了仅在高API级别上可用的全息颜色,而您的设备不知道如何处理它,因此它为文本提供了默认颜色,即黑色,恰好是微调器中背景的颜色。是的,这是一个疯狂的猜测

你尝试过什么,有没有代码示例,你使用的是什么设备等等?它们(设备和模拟器)是否运行相同的API级别?如果他使用带有微调器的setText(),他甚至无法编译代码。Vikalp Patel编辑了这篇文章,并为“设置文本”使用了一个代码块,但OP用了一种我认为更通用的方式。
spinner_type = (Spinner) findViewById(R.id.spinner_type_susa);
spinner_type.setOnItemSelectedListener(this);

ArrayAdapter<String> adapter_type = new ArrayAdapter<String>(this,R.layout.spinner_row,type_array);
adapter_type.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_type.setAdapter(adapter_type);