【问题标题】:How to change Custom Spinner Text color android如何更改自定义微调器文本颜色android
【发布时间】:2017-06-08 04:19:59
【问题描述】:

我正在开发一个 android 项目,我必须在注册表单中实现一个自定义微调器,以选择职业、姓氏。微调器功能运行良好,但微调器是自定义微调器,它不接受要更改的文本颜色。有什么办法可以改变文字的颜色吗?

下面是我的 xml 代码:

<com.infantstudio.CatholicMithrulu.Spinner.SearchableSpinnerProfestion
    android:id="@+id/profestion_spinner"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:entries="@array/profestion"
    app:hintTextCountry="Select"/>

【问题讨论】:

  • 发布微调器的行文件,你有没有给 textview 的文本颜色?

标签: android xml textview spinner


【解决方案1】:

您说您正在使用自定义微调器。您还应该将数据与自定义视图或自定义列表绑定。您应该更改自定义列表的文本颜色。

【讨论】:

    【解决方案2】:

    要创建自定义微调器,您需要设置自定义布局,在其中更改文本颜色,如下例所示

    ArrayAdapter<String>  arrayAdapter = new ArrayAdapter<String>(this, R.layout.spinner_adapter, getResources().getStringArray(R.array.profestion));
        profestion_spinner.setAdapter(arrayAdapter);
    

    您可以在此处更改文本颜色:- spinner_adapter.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="@dimen/_12sdp"
        android:padding="@dimen/_8sdp"
        android:textColor="@color/txt_color">
    
    </TextView>
    

    【讨论】:

      【解决方案3】:

      如果您使用 spinner_adapter.xml,您可以设置文本颜色。但是,如果您想根据条件值动态更改文本颜色,这是行不通的

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-08-21
        • 1970-01-01
        • 2016-09-28
        • 1970-01-01
        • 1970-01-01
        • 2014-07-02
        • 1970-01-01
        相关资源
        最近更新 更多