【问题标题】:Change text color Spinner Item showing更改文本颜色微调器项目显示
【发布时间】:2014-02-11 14:28:19
【问题描述】:

我使用了简单的光标适配器来设置微调器的适配器,因为我使用了 sqlite 数据库。但我无法自定义微调器的字体颜色,

Image

这是我的微调器的网址,背景为深红色,我想使用带有微调器 android 的简单光标适配器将文本颜色更改为白色

代码:

    Cursor cursor = dbAdapter.getAllData();

    if(cursor.getCount()>0){
    String[] from = new String[]{"columm_name"};
    // create an array of the display item we want to bind our data to
    int[] to = new int[]{android.R.id.text1};
    SimpleCursorAdapter mAdapter = new SimpleCursorAdapter(this, android.R.layout.simple_spinner_item, cursor, from, to);

    mAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerName.setAdapter(mAdapter);

【问题讨论】:

  • 希望链接能帮到你,stackoverflow.com/questions/5836254/…问候
  • 使用 ArrayAdapter 我可以使用 ArrayAdapter 进行更改,但不能使用 SimpleCurssor 适配器。当我在简单的光标适配器中使用我自己的文本视图时,它不显示任何文本

标签: android spinner


【解决方案1】:

解决我的问题希望对其他人有所帮助。

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/text1" style="?android:attr/spinnerItemStyle"
    android:singleLine="true" android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:ellipsize="marquee" android:textColor="#ffffff"/>

只需给这个 textview android 简单光标适配器代替 android.R.layout.simple_spinner_item

【讨论】:

    猜你喜欢
    • 2014-11-18
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多