我把这个XML风格在我的应用程序,但是当我打开一个微调,我不能看到的文字。 这是信息检索需要place.I真的不知道我做错了。
I set this XML Style in my app, but when I open a Spinner I cant see the text. This is where searching of information takes place.I don't really know what I am doing wrong.
这是XML风格:
<style name="Theme.Color" parent="android:Theme">
<item name="android:textColor">#FFFFFF</item>
<item name="android:windowBackground">@drawable/fondo2</item>
</style>
在微调的这种的XML:
This the XML of the Spinner:
<Spinner
android:id="@+id/spAnswers"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvSecurity"
android:entries="@array/box" />
当我打开一个微调这种情况下,我不能看到文本(文本颜色为白色)。
And when I open a Spinner this happens, I cant see the text (text color is white).
我需要将文字颜色设置为另一个微调的,只有当它打开或文本变化的背景下。
I need to set the text color to another of the spinner only when it is open or the background of the text changes.
推荐答案
在创建适配器的微调给自定义布局,而不是predefined一个
While Creating Adapter for your Spinner give custom layout instead of predefined one
创建XML命名spinner_row.xml
Create xml named spinner_row.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/cust_view"
android:layout_width="match_parent"
android:textColor="@color/black"
android:textSize="12dp"
android:layout_height="36dp"
android:gravity="left|center_vertical"/>
在这里,您可以通过修改这个TextView的更改微调元素的彩色文本的大小和宽度和高度
Here you can change the color Text size and width and height of the Elements in the spinner by modifying this textview
使用像这样在创建适配器
Use it like this while creating Adapter
ArrayAdapter<String> adapter=new ArrayAdapter<String>(context, R.layout.spinner_row,yourlist);
最后的任务是常规
The Last task is routine
spinner.setAdapter(adapter);
我希望这会帮助你。
I hope this will help you.
相关推荐
最新文章