如何在EditText和Spinner之间转换?

时间:2016-04-09 09:04:19

标签: android xml android-layout xamarin

我在TextInputLayout中包含了一个Edittext。我尝试使用 android:nextFocusForward =" @ + id / spinnerLanguage" 以便我可以获得微调器的焦点。这不起作用。我甚至尝试使用android:nextFocusUp,这种方法似乎无法正常工作

<android.support.design.widget.TextInputLayout
            android:id="@+id/txtEmailAddressWrapper"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
          <EditText
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:text=""
              android:hint="EMAIL ADDRESS"
              android:padding="5dp"
              android:id="@+id/txtEmailAddress"
              android:nextFocusForward="@+id/spinnerLanguage"
              android:inputType="text"
              android:maxLength="40" />
        </android.support.design.widget.TextInputLayout>

        <fr.ganfra.materialspinner.MaterialSpinner
            android:id="@+id/spinnerLanguage"
            android:layout_width="match_parent"
            app:ms_floatingLabelColor="@color/colorAccent"
            android:layout_height="wrap_content"
            app:ms_enableFloatingLabel="true"
            app:ms_hint="LANGUAGE" />

1 个答案:

答案 0 :(得分:0)

试试这个

txtEmailAddress.setFocusableInTouchMode(true);

txtEmailAddress.setFocusable(false);

并使用它来清除focous

txtEmailAddress.clearFocus();

或在xml中使用它

android:focusable="true"
android:focusableInTouchMode="true"

可能会帮助你

相关问题