安卓。活动启动时自动聚焦文本视图

dav*_*avs 5 android focus android-edittext

我有一个活动,该视图有几个 EditText 组件。

当活动开始时,第一个 EditText 获得焦点并出现键盘。我想避免这个“功能”(我的意思是我希望活动开始后不会有弹出键盘)

evi*_*one 4

创建一个 LinearLayout (我不知道其他类型的布局是否有效)。设置属性android:focusable="true"android:focusableInTouchMode="true"

<!-- 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/text"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:nextFocusUp="@+id/text" android:nextFocusLeft="@+id/text"/>
Run Code Online (Sandbox Code Playgroud)