【问题标题】:How to make previous editText not active when a spinner is selected选择微调器时如何使以前的editText不活动
【发布时间】:2019-01-15 20:52:02
【问题描述】:

this 来自我的 xml 文件:

<android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp">

        <android.support.design.widget.TextInputEditText
            android:id="@+id/editTextDonorName"
            android:inputType="textPersonName"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Name" />
    </android.support.design.widget.TextInputLayout>

    <android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="16dp">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Category"
            style="@style/InputLabel" />
    <Spinner
        android:id="@+id/editTextCategory"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:hint="Category"
        android:inputType="text"
        android:padding="10dp" />
    </android.support.design.widget.TextInputLayout>

这是我选择微调器时得到的 https://i.stack.imgur.com/dm8Ts.jpg

因此,如您所见,editTextDonorName 仍处于活动状态,就好像它仍处于选中状态一样。我希望它不是,并在选择微调器时更改 textView“类别”的颜色。

【问题讨论】:

    标签: android xml spinner


    【解决方案1】:

    在微调器的点击监听器中添加 requestFocus(); 这将使编辑文本失去焦点并返回到您想要的颜色。

    【讨论】:

      猜你喜欢
      • 2014-10-06
      • 1970-01-01
      • 2018-07-10
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      • 2017-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多