如何更改微调文字大小和文字颜色? [英] How to change spinner text size and text color?
问题描述
在我的Android应用程序,我使用的微调,我也装从SQLite数据库数据到微调,和它的正常工作。这里是code为。
In my Android application, I am using spinner, and I have loaded data from the SQLite database into the spinner, and it's working properly. Here is the code for that.
Spinner spinner = (Spinner) this.findViewById(R.id.spinner1);
List<String> list = new ArrayList<String>();
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String> (this,android.R.layout.simple_spinner_item, list);
cursor.moveToFirst();
list.add("All Lists");
if (cursor.getCount() > 0) {
for (int i = 0; i < cursor.getCount(); i++) {
keyList[i] = cursor.getString(cursor.getColumnIndex(AndroidOpenDbHelper.KEYWORD));
list.add(keyList[i]);
cursor.moveToNext();
}
}
Database.close();
cursor.close();
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(dataAdapter);
现在我想改变文字颜色和文字大小微调的数据。我已经使用下面的XML行到我的微调标签上我的XML文件,但它不能正常工作。
Now I want to change the text color and text size of spinner data. I have used following XML lines to my spinner tag on my XML file, but it is not working.
android:textColor="@android:color/white"
android:textSize="11dp"
我如何可以改变文字颜色和文字大小我的飞旋的?
How can I change the text color and text size of my spinner?
推荐答案
请自定义XML文件为您的微调选项。
Make a custom XML file for your spinner item.
spinner_item.xml:
给您的自定义颜色和大小,在这个文件中的文本。
Give your customized color and size to text in this file.
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:gravity="left"
android:textColor="#FF0000"
android:padding="5dip"
/>
现在使用此文件来显示你的微调的项目,如:
Now use this file to show your spinner items like:
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spinner_item,list);
您不必设置下拉资源。这将需要 spinner_item.xml
只显示在微调您的项目。
You don't need to set the drop down resource. It will take spinner_item.xml
only to show your items in spinner.
这篇关于如何更改微调文字大小和文字颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!