android - 如何显示带标签的微调器(静态文本)?

标签 android spinner

我想展示上面带有静态小标签的微调器,这是怎么可能的 看到一个流行的应用程序想要显示相同的内容。

这是我的图片,红色标记的是上面有灰色文本的微调器,它不会改变

我不想显示在微调器中显示默认文本的 android:prompt 想要在同一控件中精确显示微调器上方

enter image description here

最佳答案

为此,您必须创建自定义微调器:

根据您的需要将微调器布局命名为custom_spinner:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tVStaticSmallLabel"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="static text"
        android:textColor="#777777"
        android:textSize="22px" />

    <TextView
        android:id="@+id/tVMainText"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/tVStaticSmallLabel"
        android:layout_marginTop="5dip"
        android:text="your changing text" />
</RelativeLayout> 

在 Activity 中将此布局提供给微调器:

Spinner mySpinner = (Spinner) findViewById(R.id.yourSpinner);
        mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner,
                spinnerValues));

关于android - 如何显示带标签的微调器(静态文本)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20853062/

相关文章:

android - Phonegap/Pushwoosh/Android - 推送通知不起作用

android - kivy - python - Spinner 输出文本/字符串如何使用

android - 制作 View "GONE"会导致其下方的 View 也不可见

java - 选择微调器项目时,所选项目更改为第一个项目

android - 无法在Android Studio中使用Gradle构建项目

android - 我如何让 ExoPlayer 在我的 Activity 的 onStart() 方法中恢复视频?

javafx - 如何在 JavaFx 中的微调器中显示本地时间(小时数)

java - Android Spinner 每行的不同背景

java - 由于未找到 JRE,Eclipse 无法打开

java - getWritableDatabase 不起作用