当 Android 中的 Activity 启动时,如何阻止 EditText 获得焦点?

将标签android:focusableInTouchMode="true"和添加android:focusable="true"到父布局(例如LinearLayoutConstraintLayout)(如下例所示)将解决该问题。

<!-- Dummy item to prevent AutoCompleteTextView from receiving focus -->
<LinearLayout
    android:focusable="true" 
    android:focusableInTouchMode="true"
    android:layout_width="0px" 
    android:layout_height="0px"/>

<!-- :nextFocusUp and :nextFocusLeft have been set to the id of this component
to prevent the dummy from receiving focus again -->
<AutoCompleteTextView android:id="@+id/autotext"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:nextFocusUp="@id/autotext" 
    android:nextFocusLeft="@id/autotext"/>

当 Android 中的 Activity 启动时,如何阻止 EditText 获得焦点?

相关文章:

你感兴趣的文章:

标签云: